1、打开编辑器,为这个程序写上注释内容。#php中如何创建一个构造函数
2、创建一个类test1
3、然后利用__construct来创建一个类。function __construct($name,$age){
4、在构造函数中写上主体内容。function __construct($name,$age){ ec茑霁酌绡ho "my name is".$name." and my age is".$age; }
5、然后实例化一个对象。$t1=new test1();
6、为这个实例化对象传递两个参数。$t1=new test1("luo",29);
7、打开浏览器进行测试,输入地址http://localhost/nodepad/new%201.php