本文整理汇总了PHP中person::set_name方法的典型用法代码示例。如果您正苦于以下问题:PHP person::set_name方法的具体用法?PHP person::set_name怎么用?PHP person::set_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类person
的用法示例。
在下文中一共展示了person::set_name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: person
<?php
include "class_person.php";
?>
<html>
<head>
<title>PHP Class Implementation</title>
</head>
<body>
<?php
$ram = new person("Ram Krishna Maharjan");
$shyam = new person("Shayam Prashad Karki");
$ram->set_name("Ram Kumar Maharjan");
$shyam->set_name("Shyam Karki");
print "Ram's full name: " . $ram->get_name();
print "<br>Shyam's full name: " . $shyam->get_name();
?>
<?php
//print "<h2>Private Attribute testing</h2>";
//print "Tell me private stuff: " . $ram->pinn_number; //throws an error
$ram->set_pinn_number("1234-5423-9873");
print "<br><br>Showing Private variable: " . $ram->get_pinn_number();
?>
</body>
</html>
示例2: set_name
function set_name($new_name)
{
//$this->name=strtoupper($new_name);
person::set_name($new_name);
//static access use double colon sign (::)
parent::set_name($new_name);
//static access can access class from parent class 1 level
}
示例3: set_name
protected function set_name($new_name)
{
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
} else {
if ($new_name == "Johnny Fingers") {
person::set_name($new_name);
}
}
}
示例4: person
<head>
<meta charset="UTF-8">
<title>OOP in PHP</title>
<?php
//Include your class in your main PHP page
include "class.php";
?>
</head>
<body>
<?php
//To create an object out of a class, you need to use the 'new' keyword.
$stephan = new person();
$jimmy = new person();
// Set an objects properties
$stephan->set_name("Stephan Mcgregory");
$jimmy->set_name("Jimmy Wanjala");
//Accessing an object's data using ->
echo "Stephans full name is " . $stephan->get_name();
echo "Jimmy's full name is" . $jimmy->get_name();
?>
</body>
</html>
示例5: person
<?php
include "class_lib.php";
$stefan = new person('bob');
$stefan->set_name("Stefan Mischook");
$jimmy = new person('nick jimmy');
echo "Stefan's full name: " . $stefan->get_name();
echo "Nick's full name: " . $jimmy->get_name();
// $stefan = new person("Stefan Mischook");
$stefan->pinn_number;