Skip to content

Commit

Permalink
Merge pull request codeguy#123 from jeremeamia/gh-pages
Browse files Browse the repository at this point in the history
Added improvements and content in the programming paradigms section
  • Loading branch information
Phil Sturgeon committed Jul 18, 2012
2 parents 6940a31 + 2d59716 commit 468f6e1
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions _posts/03-02-01-Programming-Paradigms.md
Expand Up @@ -4,18 +4,21 @@ isChild: true

## Programming Paradigms

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).
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).

### Object-oriented Programming

PHP has a very complete set of object-oriented programming features including support for classes, abstract classes,
interfaces, inheritence, constructors, cloning, exceptions, and more.

* [Read about Object-oriented PHP][oop]
* [Read about Traits][traits]

### Functional Programming

PHP has had anonymous functions since PHP 5.3:
PHP has had support for anonymous functions and closures since PHP 5.3:

{% highlight php %}
<?php
Expand All @@ -27,13 +30,20 @@ $greet = function($name)
$greet('World');
{% endhighlight %}
* [Read about Anonymous functions][anonymous-functions]
PHP 5.4 added the ability to bind closures to an object's scope and also improved support for callables such that they
can be used interchangeably with anonymous functions in almost all cases.
* [Read about Anonymous Functions][anonymous-functions]
* [Read about the Closure class][closure-class]
* [Read about Callables][callables]
* [Read about dynamically invoking functions with `call_user_func_array`][call-user-func-array]
### Meta Programming
Ruby developers often say that PHP is lacking `method_missing`, but it is available as `__call()`. There are many Magic Methods available
like `__get()`, `__set()`, `__clone()`, `__toString()`, etc.
PHP supports various forms of meta programming through mechanisms like the Reflection API and Magic Methods. There are
many Magic Methods available like `__get()`, `__set()`, `__clone()`, `__toString()`, `__invoke()`, etc. that allow
developers to hook into class behavior. Ruby developers often say that PHP is lacking `method_missing`, but it is
available as `__call()` and `__callStatic()`.
* [Read about Magic Methods][magic-methods]
* [Read about Reflection][reflection]
Expand All @@ -42,6 +52,8 @@ like `__get()`, `__set()`, `__clone()`, `__toString()`, etc.
[overloading]: http://uk.php.net/manual/en/language.oop5.overloading.php
[oop]: http://www.php.net/manual/en/language.oop5.php
[anonymous-functions]: http://www.php.net/manual/en/functions.anonymous.php
[closure-class]: http://php.net/manual/en/class.closure.php
[callables]: http://php.net/manual/en/language.types.callable.php
[magic-methods]: http://php.net/manual/en/language.oop5.magic.php
[reflection]: http://www.php.net/manual/en/intro.reflection.php
[traits]: http://www.php.net/traits
Expand Down

0 comments on commit 468f6e1

Please sign in to comment.