我开始学习PHP。
此代码有什么问题?
<?php
class Cat
{
public $isAlive= true;
public $numLegs=4;
public $name="";
public function __construct($name)
{
$this->name=$name;
}
public meow()
{
return "Meow meow";
}
}
$cat1=new Cat("CodeCat")
echo $cat1->meow();
?>
如何在php函数中返回字符串?
答案 0 :(得分:1)
您错过了单词“ 功能”:
public function meow()
{
return "Meow meow";
}
和;
$cat1=new Cat("CodeCat");
echo $cat1->meow();
您应该更认真地学习PHP