<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>表达式</title>
</head>
<body>
<?php
date_default_timezone_set("Asia/Shanghai");
#表达式
/**
* 执行运算符反引号``,运行DOS或linux命令
*/
function demo() {
$output = ` dir `;
echo "<pre> $output </pre>" ;
// $output_linux = `ls -al`;
// echo "<pre> $output_linux </pre>" ;
}
// demo();
/**
* 错误控制运算符'@', 用于隐藏错误信息,但set_error_handler设置的自定义错误处理函数仍然会被调用
*/
function demo2() {
$my_file = @ file ( 'non_existent_file' ) or die ( "Failed opening file: error was ' $php_errormsg '" );
$value = @ $cache [ $key ];
}
// demo2();
/**
* 数组运算符
*/
function demo3() {
$a = array(
'a' => 'A'
);
$b = array(
'a' => 'AA',
'b' => 'B'
);
var_dump($a + $b);
echo '<br>';
var_dump($b + $a);
}
// demo3();
/**
* 类型运算符
* instanceof
* tips: 也可用于继承的子类或继承接口的子类判断
*/
function demo4() {
class MyClass {}
class NotMyClass {}
$a = new MyClass();
var_dump($a instanceof MyClass);
echo '<br>';
var_dump($a instanceof NotMyClass);
}
demo4();
?>
</body>
</html>
PHP:表达式
最新推荐文章于 2021-03-29 09:36:49 发布