Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 20f0e69

Browse files
committed
Prototype
1 parent 3b8b0de commit 20f0e69

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

‎Prototype/index.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/**
4+
* Design pattern "Prototype" (Creational)
5+
* This is demo code
6+
* See for details: http://maxsite.org/page/php-patterns
7+
*/
8+
9+
/**
10+
* Any Class
11+
*/
12+
class MyClass
13+
{
14+
/**
15+
* Any methods
16+
*/
17+
public function method()
18+
{
19+
echo 'MyClass method <br>';
20+
}
21+
}
22+
23+
24+
/**
25+
* demo
26+
*/
27+
28+
/**
29+
* create Class
30+
*/
31+
$my = new MyClass();
32+
33+
/**
34+
* clone class
35+
*/
36+
$clone = clone $my;
37+
$clone->method();
38+
/*
39+
MyClass method
40+
*/
41+
42+
/**
43+
* delete MyClass
44+
*/
45+
unset($my);
46+
47+
/**
48+
* clone lives
49+
*/
50+
$clone->method();
51+
/*
52+
MyClass method
53+
*/
54+
55+
56+
# end of file

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See details on http://maxsite.org/page/php-patterns
1414
* "Strategy" (Behavioral)
1515
* "Adapter" (Structural)
1616
* "Observer" (Behavioral)
17+
* "Prototype" (Creational)
1718

1819

1920
(c) MaxSite.org, 2019, http://maxsite.org/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /