看了些PHP的基础知识,自己在这里总结下:
1、在HTML嵌入PHP脚本有三种办法:
| <scriptlanguage="php"> //嵌入方式一 echo("test"); </script> <? //嵌入方式二 echo"<br>test2"; ?> <?php //嵌入方式三 echo"<br>test3"; ?> |
| <? //这里是单行注释 echo"test"; /* 这里是多行注释!可以写很多行注释内容 */ ?> |
| <? $a=1; functiontest(){ echo$a; } test();//这里将不能输出结果“1”。 functiontest2(){ global$a; echo$a; } test2();//这样可以输出结果“1”。 ?> |
| <? //变量的变量 $a="hello"; $$a="world"; echo"$a$hello";//将输出"helloworld" echo"$a${$a}";//同样将输出"helloworld" ?> <? //变量的函数 functionfunc_1(){ print("test"); } functionfun($callback){ $callback(); } fun("func_1");//这样将输出"test" ?> |
| <? $a[0]="abc"; $a[1]="def"; $b["foo"]=13; $a[]="hello";//$a[2]="hello" $a[]="world";//$a[3]="world" $name[]="jill";//$name[0]="jill" $name[]="jack";//$name[1]="jack" ?> |
| <? //方法一: functionfoo(&$bar){ $bar.="andsomethingextra"; |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号