<html>
<head>
<title>PHP 类</title>
</head>
<body>
<?php
class HelloWorld
{
//成员变量
private $world = "World";
//构造函数 == function __construct( $world ){....}
function HelloWorld( $world )
{
$this->world = $world;
}
//析构函数,脚本关闭时调用
function __destruct()
{
echo "out";
}
//函数
function getHtml()
{
return "Hello, ".$this->world."!";
}
}
$greetings = new HelloWorld("mini");
echo $greetings->getHtml();
; ?>
</body>
</html>
PHP 之 类
最新推荐文章于 2022-10-18 23:18:47 发布