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 ??? 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 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) 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. 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. 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
Archived
This topic is now archived and is closed to further replies.