php5的oop2--定义方法和属性

为类定义方法和属性
 
php5的oop2--定义方法和属性<?php 
php5的oop2--定义方法和属性//缺省值须是常量,不可以是变量,或类成员或方法调用 
php5的oop2--定义方法和属性class    A 
php5的oop2--定义方法和属性
php5的oop2--定义方法和属性        // 属性(成员)声明 
php5的oop2--定义方法和属性        public $aa = '缺省值'; 
php5的oop2--定义方法和属性        public $bb=array("苹果","葡萄","香蕉"); 
php5的oop2--定义方法和属性 
php5的oop2--定义方法和属性        // 方法声明 
php5的oop2--定义方法和属性        public function echo_aa() { 
php5的oop2--定义方法和属性                echo $this->aa;//not $this->$aa 
php5的oop2--定义方法和属性        } 
php5的oop2--定义方法和属性
php5的oop2--定义方法和属性 
php5的oop2--定义方法和属性$a=new A; 
php5的oop2--定义方法和属性$a->echo_aa();//缺省值 
php5的oop2--定义方法和属性?>
 
 



本文转自 xcf007 51CTO博客,原文链接:http://blog.51cto.com/xcf007/106086,如需转载请自行联系原作者

上一篇:linux 设置代理 安装jdk mysql tomcat redis hadoop


下一篇:mac mysql 下载安装navicat 终端命令行执行