急急急,求教大神,php类中不同方法怎么共用一个属性?
例如我定义一个$timestamp;在先执行index()方法时赋初值,在执行upload()需要再取出index()给的值。请问这么怎么不行?classUploadCo...
例如我定义一个 $timestamp;在先执行index()方法时赋初值,在执行upload()需要再取出index()给的值。请问这么怎么不行?
class UploadController extends Controller{
public $timestamp;
public function index(){
$this->timestamp = time();
}
public function upload(){
echo $this->timestamp;
} 展开
class UploadController extends Controller{
public $timestamp;
public function index(){
$this->timestamp = time();
}
public function upload(){
echo $this->timestamp;
} 展开
1个回答
2015-08-21
展开全部
function __construct(){
$this->index();
}
$this->index();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询