Skip to content

Commit 384345f

Browse files
author
Phil Sturgeon
committed
Some examples and notes for programming paradigms.
1 parent 9c8020f commit 384345f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

_posts/03-02-01-Programming-Paradigms.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ isChild: true
44

55
## Programming Paradigms
66

7-
PHP is a flexible, dynamic language that supports a variety of programming techniques. It has evolved dramatically over the years, notably adding a solid object-oriented model in PHP 5.0 (2004), anonymous functions and namespaces in PHP 5.3 (2009), and traits in PHP 5.4 (2012).
7+
PHP is a flexible, dynamic language that supports a variety of programming techniques. It has evolved dramatically over the years,
8+
notably adding a solid object-oriented model in PHP 5.0 (2004), anonymous functions and namespaces in PHP 5.3 (2009), and traits in
9+
PHP 5.4 (2012).
810

911
### Object-oriented Programming
1012

@@ -13,15 +15,31 @@ PHP is a flexible, dynamic language that supports a variety of programming techn
1315

1416
### Functional Programming
1517

18+
PHP has had annonymous functions since PHP 5.3:
19+
20+
{% highlight php %}
21+
<?php
22+
$greet = function($name)
23+
{
24+
print("Hello {$name}");
25+
};
26+
27+
$greet('World');
28+
{% endhighlight %}
29+
1630
* [Read about Anonymous functions][anonymous-functions]
1731
* [Read about dynamically invoking functions with `call_user_func_array`][call-user-func-array]
1832
1933
### Meta Programming
2034
35+
Ruby developers often say that PHP is lacking `method_missing`, but it is available as `__call()`. There are many Magic Methods available
36+
like `__get()`, `__set()`, `__clone()`, `__toString()`, etc.
37+
2138
* [Read about Magic Methods][magic-methods]
2239
* [Read about Reflection][reflection]
2340
2441
[namespaces]: http://php.net/manual/en/language.namespaces.php
42+
[overloading]: http://uk.php.net/manual/en/language.oop5.overloading.php
2543
[oop]: http://www.php.net/manual/en/language.oop5.php
2644
[anonymous-functions]: http://www.php.net/manual/en/functions.anonymous.php
2745
[magic-methods]: http://php.net/manual/en/language.oop5.magic.php

0 commit comments

Comments
 (0)