Your question makes no sense.
For C programming, the use of a static variable has two uses: One reason is to hide the variable from other modules. The scope of the static variable is limited to the compilation unit that it is described in. The second use of a static variable is to keep the value of the variable intact through the entire program execution unit.
Use the "static" keyword to declare a static variable within a function like shown below. <?php function fun() { static $variable; static $another_variable = ''; } ?>
static: we can use the keyword static either to method or to a variable. when we declare to a method,(eg: public static void main(String args[]),we can use this method without any object. when we use to a variable,there will be only one instance of that variable irrespective of how many objects that get created of that class. Final: Usage of final to method or to a variable makes them as constant. It's value cannot be changed...
static reference type
No. A static member variable is local to the class in which it is declared (much like a global, but scoped to the class) and is accessible to all instances of the class. Since it does not belong to any one instance of the class, it cannot be accessed via the this pointer, as you can with non-static members. Implicitly accessing the variable is the same as explicitly accessing it via ::.Note that it is possible to access a static member variable from outside the class by providing an accessor (getter) for it within the class. The accessor should be static as well, but needn't be, but it should return by value, otherwise it is no better than a global.
PHP static can only be initialized using a literal or constant. You can not use an expression. You can initialize it to an integer but you may not to another variable.
Global Varible: The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts. Static Variable : If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself. All the Best Annapurna
A static method is a method that is a class method and is not attached to the object of that class. So if we use a non static variable of the class, it would most probably not have been initialized because no object could have been created for the class. Hence it would throw a null pointer exception. To avoid such an ambiguity, there is a restriction that static methods can use only static variables. This is to ensure that class methods can access only class variables both of which would get initialized simultaneously.
-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )
"A class containing a static variable that stores a unique, and inaccesibleto external classes (private), intance of itself. The static variable isaccessed by a static method, with public access, usually called getIntance.The static variable is initiated by the static getInstance method thatvalidates wether or not the static variable already exits. If the staticvariable has not being initiated, a new instance of the class is createdand assigned to the static variable which reference is then returned by themethod. If the static variable was previously created, the method willreturn a reference to the static variable." 1A Singleton class is used when you wish to restrict instantiation of a class to only one object."Simple Singleton Pattern Example in AS3class Data{private static var dataInstance:Data;public static function getInstance():Data{if(!dataInstance) dataInstance = new Data();return dataInstance;}public function Data(){if(dataInstance) throw Error("instance exists, please use Data.getInstance()");}}" 21 [Daniel Guzman - AS3 Object Oriented Programming]2 [Daniel Guzman - AS3 Object Oriented Programming]
If this is a homework assignment, you really should try to answer it on your own first, otherwise the value of the reinforcement of the lesson due to actually doing the assignment will be lost on you.A static variable outside of a class is a variable whose value persists for the duration of the program's run time. Even if the variable goes out of scope, when it goes back into scope its value will be the last value that was assigned to it.A static variable inside a class is a variable that is part of the entire class definition. There is only one copy of that variable, and it is shared by all instances of the class.A static function is a method of a class that can only access static variables. It cannot access instance variables because it has no this pointer associated with its invocation. It is useful because you do not need an instance of the class to invoke it, so you can use it to iniitialize static class variables.// using ellipses (...) to indicate tabs for clarityclass myclass {... static c_Instances;... static initClass () {... ... c_Instances = 0;... }... myclass () { // constructor... ... c_Instances++;... ... // other stuff... }... ~myclass () { // destructor... ... c_Instances--;... ... // other stuff... }... // other stuff}// out of class invocationmyclass::initClass ();
A static variable is a variable that retains it's value over multiple calls to the function. When it is defined using the static keyword, that defining value is applied only on the first use. For example: function foo(){ static $bar = 5; $bar++; echo $bar . "\n"; } foo(); foo(); foo(); foo(); foo(); This code would output the following: 6 7 8 9 10