【发布时间】:2016-03-03 16:07:51
【问题描述】:
我习惯在这样的 php 函数中设置和声明我的参数:
函数 foo( $length = 24 ) { ...
现在我想用一个类函数来做到这一点:
class foo{
function configuration() {
$this->defaultLength = 24;
}
function foo() {
$this->configuration();
}
function test($length = $this->defaultLength) {...
通过调用:
$r = new foo();
$r->test();
我收到以下错误消息: 解析错误:语法错误,/www/htdo 中的意外“$this”(T_VARIABLE)..
如何在 php 类中定义和声明变量?
【问题讨论】:
标签: php