Home  >  Article  >  Backend Development  >  经典事例:面向对象版图形计算器

经典事例:面向对象版图形计算器

WBOY
WBOYOriginal
2016-06-13 11:53:22843browse

经典例子:面向对象版图形计算器
在index.php文件中有
echo new Form("index.php");    //Form是一个类,里面有构造方法。
      
echo new Result();   
这是什么意思,new不是创建对象吗?这样输出对象也可以啊。还有创建的对象叫什么名字?
附 :
Form类的构造方法如下:
function __construct() {
        $this->action=$action;
        $this->shape=isset($_GET["action"])?$_GET["action"]:"rect";
    }
        
------解决方案--------------------
echo new Form("index.php");  输出Form的实例化对象,它是一个对象。用echo 输出是会报错的,要用print_r(); 打印才行。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn