Home >Backend Development >PHP Tutorial > 求帮忙?php oop事例

求帮忙?php oop事例

WBOY
WBOYOriginal
2016-06-13 12:36:22860browse

求帮忙?php oop例子
class animal{
public $name="";
public $color="";
public $age="";
function getInfo(){return $this->name;}
function setInfo($name){return $this->name;}//编译器提示警告
}
$pig=new animal();
$pig->setInfo('猪');
$name=$pig->getInfo();//编译器提示错误
echo $name;


?>

PHP
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn