免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2379 | 回复: 1
打印 上一主题 下一主题

Class 类别物件--1 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-21 21:04 |只看该作者 |倒序浏览
基本语法
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

论坛徽章:
0
2 [报告]
发表于 2010-01-04 11:57 |只看该作者

北京递归科技招聘php开发工程师

要求:
熟悉PHP面向对象的设计方法,理解MVC
具有很好的代码编写能力和良好的代码编程习惯
精通Javascript,熟练掌握XHTML、CSS、DIV等页面技术,熟练应用AJAX开发
熟悉Mysql数据库应用开发,了解Mysql的数据库配置管理、性能优化
熟悉ecmall程序者优先,有移动增值行业平台开发经验者优先

公司网站  www.cngda.com
公司地址:北京市海淀区学清路金码大厦2311
简历投递邮箱chinaunix2008@gmail.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP