- <?php
- class helloworld
- {
- private
- $name="hello world";
- public
- function gethtml()
- {
- return "<html> <body>"."hello".$this->name."</html></body>";
- }
- }
- $hello=new helloworld;
- echo $hello->gethtml();
- ?>
用this指针文章类中的变量时,变量前面不加$
$this->name;
用this指针文章类中的变量时,变量前面不加$
$this->name;