Question:
PHP: 'Fatal error: Call to undefined function' but function is defined?
anonymous
2010-03-14 11:27:22 UTC
This mini-script


class test
{
public function fesql()
{
echo 'pass 1', PHP_EOL;
return;
}

public function fetch( )
{
print_r( get_class_methods( 'test' ) );
return fesql( );
}
}

$ds = new test;
$ds->fetch( );
?>

results in this output:

Array
(
[0] => fesql
[1] => fetch
)

Fatal error: Call to undefined function fesql() in test.php on line 14

The function fesql is clearly defined, yet I still get a function undefined error.

What am I overlooking???
Three answers:
Yasser Almohammad
2010-03-14 12:01:48 UTC
just use the $this operator to call another member inside the same class, it should work just fine in this function



public function fetch( )

{

print_r( get_class_methods( 'test' ) );



return $this->fesql( );

}
Web Programmer
2010-03-14 11:50:19 UTC
Do you know what version of PHP you are running? Declaring a public function is a feature of PHP 5.
anonymous
2016-04-12 08:58:00 UTC
youre probably using some sort framework and didnt read the docs... whatever youre using and whatever your editing in (you gave very little info here)...your framework expects you to define a function called siteheader() that the framework will call itself... define this.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...