About unset() within function
adolphe_ss
adolphe_ss 2017-11-08 20:50:12
0
3
1301

Please explain, please explain why the output of Mao is not 1,23;---1,23;----1,23; Good people have a safe life.

G3L48BDYD0D9X782GRMDK~V.png

That——————————————

I will put the code here first, good people will have a safe life

<?php

echo '<hr />';

function foo2(){

static $bar1;

$bar1 ;

echo "Befor unset: $bar1,<br />";

unset( $bar1 );

$bar1 = 23;

echo "after unset: $bar1\n<hr />";

}

foo2 ();

foo2 ();

foo2 ();

?>

adolphe_ss
adolphe_ss

reply all(3)
余生请多赐教

http://php.net/manual/zh/function.unset.php
The manual contains the sentence on the second floor, you can understand it

lhpllpp

If you unset() a static variable in a function, the static variable will be destroyed inside the function. However, when this function is called again, this static variable will be restored to the value it had before it was last destroyed.

This is the original words of the document! ! !

路过

There is no ‘-’ output in your code

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template