Traits中的另一个有关问题

WBOY
Release: 2016-06-13 12:54:45
Original
917 people have browsed it

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 />
Copy after login


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

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

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