WHITESPACE|2|
|
PHP_TOKEN|1|<|
PHP_TOKEN|1|?|
PHP_STRING|3|php|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_STRING|12|zend_version|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|4|

|
PHP_COMMENT_START|2|/*|
PHP_COMMENT|11| Part 1:
 |
PHP_COMMENT|1|*|
PHP_COMMENT|58| Storing the result of a function in a static variable.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|79| foo_global() increments global variable $foo_count whenever it is executed.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|76| When foo_static() is called it checks for the static variable $foo_value
 |
PHP_COMMENT|1|*|
PHP_COMMENT|79| being initialised. In case initialisation is necessary foo_global() will be
 |
PHP_COMMENT|1|*|
PHP_COMMENT|78| called. Since that must happen only once the return value should be equal.
 |
PHP_COMMENT_END|2|*/|
WHITESPACE|2|
|
PHP_VARIABLE|10|$foo_count|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_NUMBER|1|0|
PHP_SEMICOLON|1|;|
WHITESPACE|4|

|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|10|foo_global|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_GLOBAL|6|global|
WHITESPACE|1| |
PHP_VARIABLE|10|$foo_count|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|16|"foo_global()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_RETURN|6|return|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|6|'foo:'|
WHITESPACE|1| |
PHP_TOKEN|1|.|
WHITESPACE|1| |
PHP_OPERATOR|2|++|
PHP_VARIABLE|10|$foo_count|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|10|foo_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_STATIC|6|static|
WHITESPACE|1| |
PHP_VARIABLE|10|$foo_value|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|16|"foo_static()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_IF|2|if|
WHITESPACE|1| |
PHP_TOKEN|1|(|
PHP_TOKEN|1|!|
PHP_ISSET|5|isset|
PHP_TOKEN|1|(|
PHP_VARIABLE|10|$foo_value|
PHP_TOKEN|1|)|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|4|
		|
PHP_VARIABLE|10|$foo_value|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_STRING|10|foo_global|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|3|
	|
PHP_RETURN|6|return|
WHITESPACE|1| |
PHP_VARIABLE|10|$foo_value|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_COMMENT_START|2|/*|
PHP_COMMENT|11| Part 2:
 |
PHP_COMMENT|1|*|
PHP_COMMENT|73| Storing a reference to the result of a function in a static variable.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|23| Same as Part 1 but:
 |
PHP_COMMENT|1|*|
PHP_COMMENT|75| The return statment transports a copy of the value to return. In other 
 |
PHP_COMMENT|1|*|
PHP_COMMENT|77| words the return value of bar_global() is a temporary variable only valid
 |
PHP_COMMENT|1|*|
PHP_COMMENT|72| after the function call bar_global() is done in current local scope.
 |
PHP_COMMENT_END|2|*/|
WHITESPACE|2|
|
PHP_VARIABLE|10|$bar_count|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_NUMBER|1|0|
PHP_SEMICOLON|1|;|
WHITESPACE|4|

|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|10|bar_global|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_GLOBAL|6|global|
WHITESPACE|1| |
PHP_VARIABLE|10|$bar_count|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|16|"bar_global()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_RETURN|6|return|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|6|'bar:'|
WHITESPACE|1| |
PHP_TOKEN|1|.|
WHITESPACE|1| |
PHP_OPERATOR|2|++|
PHP_VARIABLE|10|$bar_count|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|10|bar_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_STATIC|6|static|
WHITESPACE|1| |
PHP_VARIABLE|10|$bar_value|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|16|"bar_static()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_IF|2|if|
WHITESPACE|1| |
PHP_TOKEN|1|(|
PHP_TOKEN|1|!|
PHP_ISSET|5|isset|
PHP_TOKEN|1|(|
PHP_VARIABLE|10|$bar_value|
PHP_TOKEN|1|)|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|4|
		|
PHP_VARIABLE|10|$bar_value|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_TOKEN|1|&|
PHP_STRING|10|bar_global|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|3|
	|
PHP_RETURN|6|return|
WHITESPACE|1| |
PHP_VARIABLE|10|$bar_value|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_COMMENT_START|2|/*|
PHP_COMMENT|27| Part 3: TO BE DISCUSSED
 |
PHP_COMMENT|1|*|
PHP_COMMENT|3|
 |
PHP_COMMENT|1|*|
PHP_COMMENT|73| Storing a reference to the result of a function in a static variable.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|69| Same as Part 2 but wow_global() returns a reference so $wow_value
 |
PHP_COMMENT|1|*|
PHP_COMMENT|75| should store a reference to $wow_global. Therefor $wow_value is already
 |
PHP_COMMENT|1|*|
PHP_COMMENT|71| initialised in second call to wow_static() and hence shouldn't call
 |
PHP_COMMENT|1|*|
PHP_COMMENT|23| wow_global() again.
 |
PHP_COMMENT_END|2|*/|
WHITESPACE|1| |
PHP_COMMENT_START|2|/*|
PHP_COMMENT|339|
$wow_count = 0;
$wow_name = '';

function &wow_global() {
	global $wow_count, $wow_name;
	echo "wow_global()\n";
	$wow_name = 'wow:' . ++$wow_count;
	return $wow_name;
}

function wow_static() {
	static $wow_value;
	echo "wow_static()\n";
	if (!isset($wow_value)) {
		$wow_value = &wow_global();
	}
	return $wow_value;
}|
PHP_COMMENT_END|2|*/|
WHITESPACE|4|

|
PHP_COMMENT_START|2|/*|
PHP_COMMENT|11| Part 4:
 |
PHP_COMMENT|1|*|
PHP_COMMENT|77| Storing a reference to a new instance (that's where the name of the  test
 |
PHP_COMMENT|1|*|
PHP_COMMENT|75| comes from). First there is the global counter $oop_global again which 
 |
PHP_COMMENT|1|*|
PHP_COMMENT|74| counts the calls to the constructor of oop_class and hence counts the 
 |
PHP_COMMENT|1|*|
PHP_COMMENT|36| creation of oop_class instances.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|71| The class oop_test uses a static reference to a oop_class instance.
 |
PHP_COMMENT|1|*|
PHP_COMMENT|74| When another oop_test instance is created it must reuse the statically
 |
PHP_COMMENT|1|*|
PHP_COMMENT|79| stored reference oop_value. This way oop_class gets some singleton behavior
 |
PHP_COMMENT|1|*|
PHP_COMMENT|69| since it will be created only once for all insatnces of oop_test.
 |
PHP_COMMENT_END|2|*/|
WHITESPACE|2|
|
PHP_VARIABLE|11|$oop_global|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_NUMBER|1|0|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CLASS|5|class|
WHITESPACE|1| |
PHP_STRING|9|oop_class|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_VAR|3|var|
WHITESPACE|1| |
PHP_VARIABLE|9|$oop_name|
PHP_SEMICOLON|1|;|
WHITESPACE|6|
	
	|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|9|oop_class|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|4|
		|
PHP_GLOBAL|6|global|
WHITESPACE|1| |
PHP_VARIABLE|11|$oop_global|
PHP_SEMICOLON|1|;|
WHITESPACE|4|
		|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|15|"oop_class()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|4|
		|
PHP_VARIABLE|5|$this|
PHP_OPERATOR|2|->|
PHP_STRING|8|oop_name|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|6|'oop:'|
WHITESPACE|1| |
PHP_TOKEN|1|.|
WHITESPACE|1| |
PHP_OPERATOR|2|++|
PHP_VARIABLE|11|$oop_global|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_CLASS|5|class|
WHITESPACE|1| |
PHP_STRING|8|oop_test|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|3|
	|
PHP_STATIC|6|static|
WHITESPACE|1| |
PHP_VARIABLE|10|$oop_value|
PHP_SEMICOLON|1|;|
WHITESPACE|6|
	
	|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|8|oop_test|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|4|
		|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|14|"oop_test()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|6|
	
	|
PHP_FUNCTION|8|function|
WHITESPACE|1| |
PHP_STRING|10|oop_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|4|
		|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|16|"oop_static()\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|4|
		|
PHP_IF|2|if|
WHITESPACE|1| |
PHP_TOKEN|1|(|
PHP_TOKEN|1|!|
PHP_ISSET|5|isset|
PHP_TOKEN|1|(|
PHP_STRING|4|self|
PHP_PAAMAYIM_NEKUDOTAYIM|2|::|
PHP_STRING|9|oop_value|
PHP_TOKEN|1|)|
PHP_TOKEN|1|)|
WHITESPACE|1| |
PHP_CURLY_OPEN|1|{|
WHITESPACE|5|
			|
PHP_STRING|4|self|
PHP_PAAMAYIM_NEKUDOTAYIM|2|::|
PHP_STRING|9|oop_value|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_TOKEN|1|&|
WHITESPACE|1| |
PHP_NEW|3|new|
WHITESPACE|1| |
PHP_STRING|9|oop_class|
PHP_SEMICOLON|1|;|
WHITESPACE|4|
		|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|
		|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_STRING|4|self|
PHP_PAAMAYIM_NEKUDOTAYIM|2|::|
PHP_STRING|9|oop_value|
PHP_OPERATOR|2|->|
PHP_STRING|8|oop_name|
PHP_SEMICOLON|1|;|
WHITESPACE|3|
	|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|2|
|
PHP_CURLY_CLOSE|1|}|
WHITESPACE|4|

|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_STRING|10|foo_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_STRING|10|foo_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_STRING|10|bar_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_STRING|10|bar_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_LINE_COMMENT|2|//|
PHP_LINE_COMMENT|25|print wow_static()."\n";
|
WHITESPACE|1|
|
PHP_LINE_COMMENT|2|//|
PHP_LINE_COMMENT|25|print wow_static()."\n";
|
WHITESPACE|1|
|
PHP_ECHO|4|echo|
WHITESPACE|1| |
PHP_CONSTANT_ENCAPSED_STRING|58|"wow_static()
wow_global()
wow:1
wow_static()
wow:1
"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_VARIABLE|11|$oop_tester|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_NEW|3|new|
WHITESPACE|1| |
PHP_STRING|8|oop_test|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_VARIABLE|11|$oop_tester|
PHP_OPERATOR|2|->|
PHP_STRING|10|oop_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_VARIABLE|11|$oop_tester|
PHP_OPERATOR|2|->|
PHP_STRING|10|oop_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_VARIABLE|11|$oop_tester|
WHITESPACE|1| |
PHP_TOKEN|1|=|
WHITESPACE|1| |
PHP_NEW|3|new|
WHITESPACE|1| |
PHP_STRING|8|oop_test|
PHP_SEMICOLON|1|;|
WHITESPACE|1| |
PHP_LINE_COMMENT|2|//|
PHP_LINE_COMMENT|11| repeated.
|
WHITESPACE|1|
|
PHP_PRINT|5|print|
WHITESPACE|1| |
PHP_VARIABLE|11|$oop_tester|
PHP_OPERATOR|2|->|
PHP_STRING|10|oop_static|
PHP_TOKEN|1|(|
PHP_TOKEN|1|)|
PHP_TOKEN|1|.|
PHP_CONSTANT_ENCAPSED_STRING|4|"\n"|
PHP_SEMICOLON|1|;|
WHITESPACE|2|
|
PHP_CLOSETAG|4|?>
|
