当前位置:编程学习 > JAVA >>

各位帮忙看看这段简单的代码,function是干什么使的,$bob那段是什么意思

class person
{
   var $name = "";
   function name($newname = NULL)
   {
       if(! is_null($newname))
       {
           $this->name=$newname;
       }
       return $this->name;
   }
   var $surname = "";
   function surname($newsurname = NULL)
   {
       if(! is_null($newsurname))
       {
           $this->surname=$newsurname;
       }
       return $this->surname;
   }
   var $age = "";
   function age($newage = NULL)
   {
       if(! is_null($newage))
       {
           $this->age=$newage;
       }
       return $this->age;
   }
}

$bob = new person;
$bob->name('Bob');
$bob->surname('Builder');
$bob->age('50');

printf("Hi %s, your surname is %s and you are %s years old", $bob->name, $bob->surname, $bob->age);

Outputs:

Hi Bob, your surname is Builder and you are 50 years old  --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 是什么意思呢  没人回答啊 --------------------编程问答-------------------- 敲木鱼是什么意思呢
引用 2 楼  的回复:
--------------------编程问答-------------------- 不会么
引用 1 楼  的回复:
补充:Java ,  Java相关
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,