1,php字符串中放置变量
php中单引号内无法解析变量:
a=123;echo′a=123;
echo 'a=123;echo′a’ ; //aecho"a
echo "aecho"a" ; // 123
但是在 数据库中插入数据时:
sqlinsert="insertintomanagersinfovalues(′sqlinsert="insert into managersinfo values('sqlinsert="insertintomanagersinfovalues(′company’,‘nam′,′nam','nam′,′job’,‘id′,′id','id′,′recordnum’,‘email′,′email','email′,′password’)";最好是外部是双引号,变量是单引号,虽然说外部双引号内可以解析变量,但是遇到过一种情况:
sql="select∗fromtables2whereid=sql="select * from tables2 where id=sql="select∗fromtables2whereid=fuck[i]";像这样的i] " ;
像这样的i]";像这样的fuck[$i],变量中又嵌套一个变量,莫名其妙的在一个文件中不加单引号就可以正确解析,但是在另一个文件中就解析不了变量了,然后在外部加了单引号才恢复正常,这说明最保险的方式是," select * from tables2 where id=’ fuck[fuck[fuck[i] ’ " ;
2,php获取对象中属性:
$jsonstring=’{ “name”: “bob”, “age”:11}’ ;
$jsonobj= php_decode( $jsonstring );
$name= $jsonobj->name;
3,php获取数组变量:
$array= [ “name”=>“bob”, “age”=>11 ];
$name= $array[“name”];
KaTeX parse error: Expected '}', got 'EOF' at end of input: …st element is {temp[“one”]}.";
php字符串中的变量到底应该怎么表达
最新推荐文章于 2024-11-06 22:29:14 发布