Chinaunix

标题: Class 类别物件--1 [打印本页]

作者: lanphp    时间: 2009-12-21 21:04
标题: Class 类别物件--1
基本语法
1:


c:\AppServ\www\phptest\class\class01.php
http://localhost/phptest/class/class01.php
1: color=$c ;
6: }
7: function get_color(){
8: return $this->color ;
9: }
10: }
11:?>
12:
13: 物件
14:
15: set_color("宝蓝色") ;
18: echo "车子的颜色是" . $MyCar->get_color() ;
19: ?>
20:
21:


c:\AppServ\www\phptest\class\class02.php
http://localhost/phptest/class/class02.php
1:item[]=$name ;
7: $this->item[]=$cost;
8: }
9: function GetItem(){
10: $c=count($this->item);
11: for ($i=0; $iitem[$i];
13: echo " => 金额 : ".$this->item[$i+1]." 元
";
14: }
15: }
16: function sum() {
17: $c=count($this->item);
18: $s=0;
19: for ($i=1; $iitem[$i];
21: }
22: return $s;
23: }
24: }
25:?>
26:
27:物件应用
28:
29:AddOneItem("主机板","3000") ;
33: $customer1->AddOneItem("显示卡","800") ;
34: $customer1->AddOneItem("记忆体","1800") ;
35: $customer2->AddOneItem("PC游戏","2500") ;
36: $customer2->AddOneItem("滑鼠","100") ;
37: $customer2->AddOneItem("无线网路卡","2500") ;
38: $customer2->AddOneItem("LCD显示器","8000") ;
39: echo "第一位顾客采购内容:
";
40: $customer1->GetItem();
41: echo "" ;
42: echo "第二位顾客采购内容:
";
43: $customer2->GetItem();
44: echo "";
45: $total=$customer1->sum()+$customer2->sum();
46: echo "今日营业额 $total 元";
47:?>
48:
49:



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/108609/showart_2127437.html
作者: mufengit    时间: 2010-01-04 11:57
标题: 北京递归科技招聘php开发工程师
要求:
熟悉PHP面向对象的设计方法,理解MVC
具有很好的代码编写能力和良好的代码编程习惯
精通Javascript,熟练掌握XHTML、CSS、DIV等页面技术,熟练应用AJAX开发
熟悉Mysql数据库应用开发,了解Mysql的数据库配置管理、性能优化
熟悉ecmall程序者优先,有移动增值行业平台开发经验者优先

公司网站  www.cngda.com
公司地址:北京市海淀区学清路金码大厦2311
简历投递邮箱chinaunix2008@gmail.com




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2