FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpHomeworks/designPatternSingleton.php at master · randomrandom/phpHomeworks · GitHub
randomrandom
/
phpHomeworks
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
phpHomeworks
/
designPatternSingleton.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (37 loc) · 665 Bytes
Breadcrumbs
phpHomeworks
/
designPatternSingleton.php
Copy path
File metadata and controls
45 lines (37 loc) · 665 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
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class
Database
{
private
$
name
;
private
$
pool
;
function
__construct
(
$
name_in
,
$
pool_in
)
{
$
this
->
name
=
$
name_in
;
$
this
->
pool
=
$
pool_in
;
}
function
query
()
{
echo
'
The database is performing a query <br />\n
'
;
}
}
class
DatabaseSingleton
{
private
static
$
theDatabase
;
private
static
$
pool
=
new
array
();
function
__construct
()
{
echo
'
The database is created<br />\n
'
;
}
function
getDatabase
()
{
if
(!
self
::
$
theDatabase
)
{
self
::
$
theDatabase
=
new
Database
(
"
databse
"
,
$
pool
);
}
return
self
::
$
theDatabase
;
}
function
query
()
{
self
::
$
theDatabase
->
query
();
}
}
?>
Back
|
FazBrowse Home
|
New Git URL