rubing Posted March 22, 2008 Share Posted March 22, 2008 I need my variable to be both global and static, but global static $var nor static global $var does not work ??? Quote Link to comment https://forums.phpfreaks.com/topic/97428-can-a-varaible-be-global-and-static/ Share on other sites More sharing options...
Psycho Posted March 23, 2008 Share Posted March 23, 2008 "static" is not even a PHP function/command. Try "define" instead to create a constant: http://us.php.net/define Quote Link to comment https://forums.phpfreaks.com/topic/97428-can-a-varaible-be-global-and-static/#findComment-498514 Share on other sites More sharing options...
Barand Posted March 23, 2008 Share Posted March 23, 2008 All variables defined at page level (not inside a function) are static mjdamato, oh yes it is <?php function testStatic () { static $a; echo ++$a, '<br />'; } testStatic(); testStatic(); testStatic(); ?> http://us3.php.net/manual/en/language.variables.scope.php (scroll down a bit) Quote Link to comment https://forums.phpfreaks.com/topic/97428-can-a-varaible-be-global-and-static/#findComment-498525 Share on other sites More sharing options...
Psycho Posted March 23, 2008 Share Posted March 23, 2008 I stand corrected - interesting that a search for "static" at php.net doesn't bring up any results. Quote Link to comment https://forums.phpfreaks.com/topic/97428-can-a-varaible-be-global-and-static/#findComment-498670 Share on other sites More sharing options...
Barand Posted March 23, 2008 Share Posted March 23, 2008 The default search is a function search. You have to search online documentation. Quote Link to comment https://forums.phpfreaks.com/topic/97428-can-a-varaible-be-global-and-static/#findComment-498720 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.