Home >Backend Development >PHP Tutorial > Traits中的另一个有关问题

Traits中的另一个有关问题

WBOY
WBOYOriginal
2016-06-13 12:54:45951browse

Traits中的另一个问题

<br />
<?php<br />
       trait Hello {<br />
		public function sayHelloWorld() {<br />
			echo 'Hello '.$this->getWorld();<br />
		}<br />
		<br />
		abstract public function getWorld();<br />
	}<br />
	<br />
	class MyHelloWorld {<br />
		use Hello;<br />
		<br />
		private $world;<br />
		public function getWorld() {<br />
			return $this->world;<br />
		}<br />
		public function setWorld($val) {<br />
			$this->world = $val;<br />
		}<br />
	}<br />
	<br />
	<br />
	$o = new MyHelloWorld();<br />
	$o->setWorld('World!');<br />
	$o->sayHelloWorld();<br />
?><br />


为什么zend studio中指明trait Hello有错?但运行是没有问题的

function zend class php
------解决方案--------------------
php 5.4 才出来几个月?

如果有还会报错吗?
Statement:
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