RE: [PHP] Function / String Problem
| From: | Boget, Chris | Date: | Fri, 19 Jan 2001 17:15:13 +0000 |
| Subject: | RE: [PHP] Function / String Problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35645@lists.php.net to get a copy of this message | ||
> echo "<br><br>...are you logged in:
> $LoggedIn()<br><br>";> //
outputs: ...are you logged in: ()
>
> Function is:
> function LoggedIn(){
> global $HTTP_POST_VARS
> if ($HTTP_POST_VARS["Login"] == "PHPIsCool")
> {return "YES";}
> else
> {return "NO";}
> }
Change your echo statement to:
echo "<br><br>...are you logged in: " . LoggedIn() .
"<br><br>";
"$LoggedIn()" looks to PHP like a variable. Any variable that is
within a double quoted string gets interpolated. Plus, you almost
never want to put a '$' in front of a function name because then
it looks like a variable function name to PHP. IOW, taking the
above function definition, you could do:
$functionName = "LoggedIn";
echo $functionName();
and PHP will run the function 'LoggedIn()'.
HTH
Chris