php variable scope

后端 未结 6 2026
栀梦
栀梦 2020-12-01 19:31

i\'m confused about the php variable scope. such as:

while(true){
    $var = \"yes , it is a test!\";
  }
  printf($var)

the $var

6条回答
  •  孤街浪徒
    2020-12-01 20:13

    Loop does not have any scope in PHP. variable is simply available outside the loop.

    just echo outside the loop;

    echo $var;

提交回复
热议问题