php基本知识(2)-特殊之处

WBOY
Release: 2016-06-13 13:20:40
Original
891 people have browsed it

php基本知识(二)--特殊之处

1、"+"不是字符串连接符,“12a”+“a”=12 ,字符串连接符为"."
2、echo gettype(-3%2); -1 保留符号、integer 
   echo gettype(-3/2); -1.5 double
3、逻辑运算符多了:xor 逻辑异或(逻辑与、逻辑或、逻辑异或、逻辑非)
4、调用父类构造函数:parent::__construct()
5、变量名可变:
$change_name = "huhu";
$huhu = "change_name变量被改变了";
echo $change_name; //输出:huhu
$$change_name = "还原了";
echo "<p>";
echo $huhu;  //输出:还原了
解析:$huhu与$$change_name指向同一块内存
6、变量函数
function go()
{
  echo "走了";
}
$func = "go";
func(); 调用了go()函数---可以用来实现回调函数、函数表但是变量函数不能用于语言结构,例如 echo()、print()、unset()、isset()、empty()、include()、require() 以及类似的语句
echo $$change_name; //输出:change_name变量被改变了
7、break $num; 跳出第几重循环,如while套for套foreach
8、switch($var)  $var:任意类型
</p>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template