凌的博客

您现在的位置是:首页  > 学无止境 > PHP

PHP

PHP7新特性

2016-07-26PHP0
//设置时区 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条评论