You are here: Re: Very basic question « All PHP « IT news, forums, messages
Re: Very basic question

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация