Back | Reverse |

PHP Global VAR.?
Link | by YoGa on 2005-08-16 05:45:28
how to get a golbal var. while running insude a function?
"global VAR;"is not working!!!
Is there another way?

YoGa

Re: PHP Global VAR.?
Link | by gendou on 2005-08-16 19:49:55 (edited 2005-08-16 19:50:45)
<?php
$var1 = 1;
$var2 = 2;
function addOneTo($input)
{
   global $var1;
   return $input + $var1 + $var2;
}
print addOneTo(10); // should print 11 not 13
?>



Re: PHP Global VAR.?
Link | by YoGa on 2005-08-17 11:07:07
THANKS VERY MUCH!!!
The problem was very simple than that!!
The problem was that I wrote "global var;" insteat of "global $var;".
Thanks again.

YoGa

Back | Reverse |

Copyright 2000-2024 Gendou | Terms of Use | Page loaded in 0.0023 seconds at 2024-05-09 10:38:34