|
Posted by Oli Filth on 09/26/06 23:23
Jerry Stuckle said the following on 26/09/2006 22:07:
> Charles O'Flynn wrote:
>> Thanks for the quick reply, Johnny, but I've been looking at the page you
>> refer to all afternoon and it doesn't seem to work for me. For instance,
>> (and I'm only illustrating the specific problem I seem to have
>> hereunder)...
>> ------------------------------------
>> $variable;
>>
>> function printsomething()
>> {
>> global $variable;
>>
>> $variable = 'Test'.<b />;
>> echo $variable;
>> }
>>
>> printsomething();
>> echo $variable;
>> ------------------------------------
>>
>> ...only prints one line of 'Test' - I'd have thought it should print
>> out two
>> copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
>> change/upgrade!)
>
> You're close. But you have to use the global keyword in the global
> context, also. Not just in the function.
Umm, no you don't!
http://uk.php.net/manual/en/language.variables.scope.php#language.variables.scope.global
>
> global $variable;
>
> function printsomething()
> {
> global $variable;
>
> $variable = 'Test'.<b />;
> echo $variable;
> }
>
> printsomething();
> echo $variable;
>
--
Oli
[Back to original message]
|