PHP7新特性
2016-07-26 PHP 809
//设置时区
date_default_timezone_set(\'Asia/Shanghai\');
echo \'当前时间:\'.date(\'Y-m-d H:i:s\');
echo \"\\n\\n\\n\";
$site = $_GET[\'site\'] ?? \'菜鸟php7\';
echo $site ;
echo \"\\n\\n\\n\";
// 整型比较
//设置时区 date_default_timezone_set('Asia/Shanghai'); echo '当前时间:'.date('Y-m-d H:i:s'); echo "\n\n\n"; $site = $_GET['site'] ?? '菜鸟php7'; echo $site ; echo "\n\n\n"; // 整型比较 print( 1 <=> 1); echo "\n\n\n"; print(PHP_EOL); echo "\n\n\n"; //定义数组 define('sites',array( 'www.baidu.com', 'www.google.com', 'www.yetyun.com', )); print_r(sites); echo "\n\n\n"; //匿名类 interface Logger{ public function log(string $msg); } class Application{ private $logger; public function getLogger():Logger{ return $this->logger; } public function setLogger(Logger $logger){ $this->logger = $logger; } } $app = new Application(); $app->setLogger(new Class implements Logger{ public function log(string $msg){ print($msg); } }); $app->getLogger()->log('匿名类: 我的第一条日志');参考:http://www.runoob.com/php/php-anonymous-classes.html
很赞哦! (0)
文章评论
-
-
-
0条评论