<?php //变量以$开始 //&引用变量 $a=5; $b=&$a; echo "b:$B"; $a=3; echo "b:$b"; $b =7; echo "a:$a"; //可变变量 $aa="hello"; $$aa="wold!"; echo $hello.$aa.$$aa;//wold!hellowold! function test() { static $count = 0;//添加static静态声音用来保存函数运行变量结束递归用,否则无限循环$count=1 $count++; echo $count." "; if ($count < 10) { test(); } $count--;//递归结束后运行 echo " .".$count; } test();//1 2 3 4 5 6 7 8 9 10 .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 //echo $count; //常量大小字敏感,可以用define(),php5.3.0后可以用const定义 define("CONSTANT","hello word."); echo CONSTANT; const CONSTANT1 = 'Hello World';//php5.3.0以下syntax error echo CONSTANT1; /*魔术常量LINE FILE DIR FUNCTION CLASS TRAIT METHOD NAMESPACE https://www.php.net/manual/zh/language.constants.predefined.php*/ ?>
https://www.php.net/manual/zh/language.variables.php
梦