本文整理汇总了PHP中person::say方法的典型用法代码示例。如果您正苦于以下问题:PHP person::say方法的具体用法?PHP person::say怎么用?PHP person::say使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类person
的用法示例。
在下文中一共展示了person::say方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
public $salary = 6720.12;
public $info = array('a' => 1, 'b' => 2, 'c' => 3);
// 方法
function say($sth)
{
echo $this->name, '说', $sth, '<br/>';
}
function study($subject)
{
echo $this->name, '在学习', $subject, '<br/>';
}
function sleep()
{
echo $this->name, '在睡觉', '<br/>';
}
}
// 创建对象
$p1 = new person();
$p1->name = '张三';
$p1->study('面向PHP对象');
// print_r($p1);
// 创建对象
$p2 = new person();
$p2->name = '李四';
$p2->say('hello world');
// print_r($p2);
// 创建对象
$p3 = new person();
$p3->name = '赵五';
$p3->sleep();
// print_r($p3);
示例2: person
echo "<hr/>";
//clone 关键词
$p1 = new person("张三", "男", "88");
$p2 = clone $p1;
$p1->name = "王麻子";
echo "<br/>";
echo $p1->name;
echo $p2->name;
echo "<hr/>";
//魔术方法 __toString() ————让 'echo $p1'不报错
echo $p1;
echo "<hr/>";
//魔术方法 __call()
$p1->run();
echo '<br/>';
$p1->say('爬', '开');
class DB
{
private $sql = array("field" => "", "where" => "", "order" => "", "limit" => "", "group" => "", "having" => "");
function __call($DBName, $args)
{
$DBName = strtolower($DBName);
if (array_key_exists($DBName, $this->sql)) {
$this->sql[$DBName] = $args[0];
} else {
echo '你调用的' . get_class($this) . '中的方法' . $DBName . '不存在!';
}
return $this;
}
function select()
{
示例3: setName
{
var $name;
var $sex;
var $age;
function setName($name)
{
$this->name = $name;
}
function getName()
{
return $this->name;
}
function say()
{
echo "my nane is:" . $this->name . "sex is:" . $this->sex . "age is:" . $this->age . "<br>";
}
function run()
{
echo $this->name . "this person on stree";
}
function __destruct()
{
echo "goodbye" . $this->name . "<br>";
}
}
$p1 = new person();
$p2 = new person("猪", "woman", 30);
$p1->setName("猪");
// $p3 = new person ( "sunfolwer", "man", 25 );
$p1->say();
示例4: say
public function say()
{
parent::say();
// 调用父类中的方法
echo $this->name, "\tis\t", $this->gender, ",and is\t", $this->age, PHP_EOL;
}
示例5: say
class person
{
public $name;
public $gender;
public function say()
{
echo $this->name . "\tis ", $this->gender, "\r\n";
}
}
class family
{
public $people;
public $location;
public function __construct($p, $loc)
{
$this->people = $p;
$this->location = $loc;
}
}
$student = new person();
$student->name = 'Tom';
$student->gender = 'male';
$student->say();
$tom = new family($student, 'peking');
echo serialize($student);
$student_arr = array('name' => 'Tom', 'gender' => 'male');
echo "\n";
echo serialize($student_arr);
print_r($tom);
echo "\n";
echo serialize($tom);