标签:oop
定义的类的文件名,命名方式:类名.class.php
compare.class.php
<?php class compare{ public $a = 100; public function getMax($a,$b){ return $a>$b?$a:$b; } } ?>
index.php
<?php include("compare.class.php"); $obj = new compare; echo $obj->a;//类外调用成员属性 echo "<hr/>"; echo $obj->a=200;//类外给成员属性重新赋值 echo "<hr/>"; echo $obj->getMax(1,2);//类外调用成员方法 ?>
本文出自 “IT5808” 博客,请务必保留此出处http://it5808.blog.51cto.com/10842703/1713155
标签:oop
原文地址:http://it5808.blog.51cto.com/10842703/1713155