php的類中可以不定義成員變量,直接在構造方法中使用并賦值嗎?class block {
function block()
{
$this->iconWidth = "23";
$this->iconHeight = "23";
$this->bgColor = "#5B7F93";
$this->fgColor = "#C4D3DB";
$this->oddColor = "#F5F5F5";
$this->evenColor = "#EFEFEF";
$this->highlightOn = "#DEE7EB"; $this->class = "odd";
$this->highlightOff = $this->oddColor;
$this->theme = THEME;
$this->pathImg = "../themes";
}
...
}
這是我看到的一個類,感覺很奇怪,它也沒有父類。
function block()
{
$this->iconWidth = "23";
$this->iconHeight = "23";
$this->bgColor = "#5B7F93";
$this->fgColor = "#C4D3DB";
$this->oddColor = "#F5F5F5";
$this->evenColor = "#EFEFEF";
$this->highlightOn = "#DEE7EB"; $this->class = "odd";
$this->highlightOff = $this->oddColor;
$this->theme = THEME;
$this->pathImg = "../themes";
}
...
}
這是我看到的一個類,感覺很奇怪,它也沒有父類。
解决方案 »
- smarty的问题,输出运算结果
- 请找出这小段代码中出现的错误,答对有奖
- 能不能修改页面里面的函数代码,在submit的时候提交自己设定的值??
- 关于数组问题
- 求助,有哪位朋友用过turbocrm的php版?
- Fatal error: Call to undefined function mysql_connect() in E:\backup\e-meeting\public_html\test.php on line 4
- 搜索出来如何让关键字如何变亮。
- 有谁写过asp的语音聊天程序?
- php对odbc数据库的操作问题,紧急!!
- dede 栏目导航添加一个封面模板的栏目,封面模板的栏目下面跟了同级栏目,其他的正常跟了子栏目
- 请问怎么修改CDATA中的内容?谢谢
- 自己写了个图片上传,有代码,怎么成功不了,在线等......
php 的变量不也都是不经声明就可使用的吗?
{
function testgo()
{
$this -> base = 'ok';
}
function echos()
{
echo $this -> base;
}
}$t = new tests();
$t -> testgo();
$t -> echos();
可以的。但最好定义先吧。可定公共或私有....==这样明了些。