Home >Backend Development >PHP Tutorial >What\'s the Deal with PHP\'s Obsolete `var` Keyword?
Deciphering PHP's 'var' Keyword: A Detailed Exploration
The 'var' keyword in PHP has been a persistent enigma, leaving many programmers scratching their heads. This article delves into its enigmatic nature, answering the following burning questions:
Usage Example
To illustrate its usage, consider the following PHP code:
class foo { var $x = 'y'; // or you can use public like... public $x = 'y'; //this is also a class member variables. function bar() { } }
In this example, 'var' is used to declare the 'x' property as a member variable within the 'foo' class. Alternatively, 'public' can be used to achieve the same effect.
The above is the detailed content of What\'s the Deal with PHP\'s Obsolete `var` Keyword?. For more information, please follow other related articles on the PHP Chinese website!