answersLogoWhite

0

How can a PHP static be initialized?

Updated: 8/20/2019
User Avatar

Wiki User

10y ago

Best Answer

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.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can a PHP static be initialized?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can array be initialized if they are static?

Yes.


What happen when static data field is initialised in a non static constructor?

It got initialized as you instructed.


Which variable is initialized once when program is compiled?

global and static


How do you create static variables in PHP?

Use the "static" keyword to declare a static variable within a function like shown below. <?php function fun() { static $variable; static $another_variable = ''; } ?>


What is isset in php?

isset( $var ) is a PHP function which returns TRUE or FALSE depending on whether a specified $var has been assigned to any value (or, initialized).


Why you say that no static binding in php?

PHP supports late static binding since version 5.3, which was officially released in June of 2009.


Are C variables initialized to 0 by default?

Only global/static variables are, local variables aren't.


Static method can use only static variable why?

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.


How does PHP differ from HTML in terms of application and structure?

In structure <?php ?> <html> </html> in application - one is static and another is dynamic. this much ......


Can static variables be changed?

No, a static variable means that there is only one copy of that variable, and it is shared by all members of the class, or by all callers of a function.A variable that is read-only would be marked as const or final (depending on language).


What is a php session?

A PHP session is a concept where specific variables (and their respective values) are carried throughout a user's viewing of a PHP-driven website. These sessions can be initialized and continued using the session_start() function. The session values are stored in the $_SESSION global variable. For more information, see the php.net documentation of session functions.


Why memory is divided into initialized and uninitialized areas?

The program's data segment. This area of memory is allocated by the linker and is used to store the program's global variables, static variables, static arrays and constants. Constants are always initialised, as are static variables, but global variables and static arrays need not be initialised.