1. 变量替换
<?php $a1="1"; $a12="2"; echo "$a12<br>"; echo "{$a12}<br>"; echo "{$a1}2<br>"; ?>
2.确定变量类型
<?php $a1="1"; echo gettype($a1)."<br>"; $a1+=1; echo gettype($a1)."<br>"; echo $a1."<br>"; $a1+=1.1; echo gettype($a1)."<br>"; echo $a1."<br>"; $a1=(array)($a1); echo $a1."<br>"; echo gettype($a1)."<br>"; settype($a1,"string"); echo $a1."<br>"; echo gettype($a1)."<br>"; ?>
运行结果
string
integer
2
double
3.1
Array
array
Array
string