Re: Problem with functions
| From: | Victor Halla | Date: | Thu, 05 Dec 2002 00:29:44 +0000 |
| Subject: | Re: Problem with functions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127067@lists.php.net to get a copy of this message | ||
Thanks !!!
Victor
"Tom Rogers" <trogers@kwikin.com> escreveu na mensagem
news:1260970010.20021205095449@kwikin.com...
> 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
>