Home  >  Article  >  Backend Development  >  种的属性不能使用时间函数啊

种的属性不能使用时间函数啊

WBOY
WBOYOriginal
2016-06-13 11:29:48750browse

类的属性不能使用时间函数啊?
代码如下,直接报错,我想做的事情是,访问一个类的属性,返回当前时间,因为我使用的是thinkphp,里面有一个地方一定是这样的:访问类属性返回当前时间,但是我这样写不行,出错,请问怎么做?

<?php<br /><br />class Mytime{<br /><br />public $time=date('Y-m-d H:i:s');<br /><br />}<br /><br /><br /><br />$mytime=new Mytime();<br /><br />$mes=$mytime->time;<br /><br />echo $mes;<br />



出错信息如下:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in C:\php\apache\htdocs\test5.php on line 5

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