Re: Problem with functions

From: Date: Wed, 04 Dec 2002 23:54:49 +0000
Subject: Re: Problem with functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127057@lists.php.net to get a copy of this message
Hi, Thursday, December 5, 2002, 9:15:53 AM, you wrote: VH> Hi, VH> I have de following code for example VH> <?php VH> $username = "victor"; VH> function test() { VH> echo $username; VH> } ?>> VH> If I call the funcion test(), echo print nothing.... what's is going on ? VH> []Žs VH> victorhalla@yahoo.com VH> __________________________________________________________________ Victor VH> Halla ICQ#: 114575440 Current ICQ status: + More ways to contact me VH> __________________________________________________________________ You need to tell the function to use the global variable like so: function test() { global $username; echo $username; } -- regards, Tom

« previous php.general (#127057) next »