Posted by J.O. Aho on 10/10/18 11:39
m6s wrote:
>
> eh... I didn't use globals directive, though it worked :-) !!
<?PHP
include_once('database.php');
function justsomething() {
global $database_user;
echo $database_user ."\n";
}
function somethingelse() {
echo $database_user ."\n";
}
echo "We now run the somethingelse() function:\n";
somethingelse(); // prints nothing at all
echo "We will now run the justsomething() function:\n";
justsomething(); // prints your database user name
?>
This simple scripts shows you how to use the global directive in functions and
you will see the difference if you don't use it when you need to use a global
variable.
//Aho
Navigation:
[Reply to this message]
|