phpオブジェクト向け1
3087 ワード
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
/**
* ,
*/
class People
{
public $ip='nami';
public function say()
{
echo "hello";
}
}
$pp=new People();
echo $pp->ip;
echo "<br>";
$pp->say();
// null
class Name{
public $a;
}
$ll=new Name();
var_dump($ll->a);
?>
</body>
</html>
/****$this-> *********/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
/**
* ,
* ,
*/
/**
*
*/
class People
{
function time()
{
echo " ",'<br/>';
}
function time2(){
// $this->time()
echo " ",'<br/>',$this->time();
// ,
echo " ",time(),'<br/>';
}
}
$p=new People();
$p->time();
$p->time2();
?>
</body>
</html>
//
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
// ,
// ,
/**
*
*
*/
class People
{
public $name=' ';
// __construct() ,new 。
public function __construct($name)
{
$this->name=$name;
echo $this->name;
}
//
public function __destruct(){
echo " ";
}
}
$a=new People('hello,world!');
unset($a);
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
/**
*
*/
class People
{
function __construct($a)
{
echo "{$a}";
}
}
$a1=new People("hello");
//
//$a,$b,$c
//unset($a1) , 0
$b1=&$a1;
unset($a1)
echo "<hr/>";
?>
</body>
</html>