FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Design-patterns/proxy.php at master · LaughingMeMe/Design-patterns · GitHub
LaughingMeMe
Design-patterns
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Design-patterns
/
proxy.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (27 loc) · 845 Bytes
Breadcrumbs
Design-patterns
/
proxy.php
Copy path
File metadata and controls
32 lines (27 loc) · 845 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
//行为型
//代理模式:代理模式跟我们PC上用的代理道理一样,主要是在我们电脑和远程站点之间加了一层代理,可以使访问透明,截取或者代理这两个对象之间的访问,过滤或增强两个对象之间的通信
class
cd{
protected
$
title
=
null
;
protected
$
band
=
null
;
public
function
__construct
(
$
title
,
$
band
){
$
this
->
title
=
$
title
;
$
this
->
band
=
$
band
;
}
public
function
buy
(){
$
sql
=
'
update num = num - 1 where title =
'
.
$
this
->
title
.
'
and band =
'
.
$
this
->
band
;
mysql_query
(
$
sql
);
}
protected
function
_connect
(){
mysql_connect
(
'
A
'
,
'
root
'
,
'
123456
'
);
mysql_select_db
(
'
cds
'
);
}
}
//hangzhoucd,基于代理模式的新对象
class
hangzhoucd
extends
cd{
protected
function
_connect
(){
mysql_connect
(
'
B
'
,
'
root
'
,
'
123456
'
);
mysql_select_db
(
'
cds
'
);
}
}
?>
Back
|
FazBrowse Home
|
New Git URL