类 myclass::abc()和$test->abc()的差异 打印 E-mail
  2008-04-25
[php]
class myclass
{
var $username = "";

function show_username()
{
$this->username = "小明";
}

function Welcome()
{
$this->show_username();
echo "欢迎".$this->username;
}
}
[/PHP]
然后使用
myclass::Welcome();
提示错误
Call to a member function on a non-object

使用
$msg = new myclass();
$msg -> Welcome();
得到
欢迎小明

看来这两种方法用起来并非很随意,不知道大家注意到了没有?或是有其它要注意的地方。
发表评论
网友评论

发表评论
用户访客
标题
BBCode:Web AddressEmail AddressBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
评论



下一篇 >