Wednesday, February 27, 2013

Relive: Barcelona 1-3 Real Madrid (King's Cup semifinal 2nd leg)

Real Madrid v Barcelona
Real Madrid's Cristiano Ronaldo from Portugal, left, challenges for the ball with Barcelona's Pedro Rodriguez during the Copa del Rey soccer match between FC Barcelona and Real Madrid in Barcelona, Spain, Tuesday, Feb. 26, 2013 (Photo: AP)

The referee blows his final whistle, Barcelona 1-3 Real Madrid

Left-back Jordi Alba holds off marker Sergio Ramos to side-foot home after a neat long ball from Iniesta. Barcelona score a consolation in the dying minutes.


A low shot by Andres Iniestia misses the target from inside the area.

85 Tempers flare with five minutes remaining after Pepe theatrically falls on the ground after being touched by Busquets.

84 Ghanaian midfielder Michael Essien replaces Xabi Alonso for Real Madrid's final substitution.

83 A counter attack ends with Ronaldo forcing a fine save from Pinto after firing a low shot from a tight angle. He continues to outpace his hapless markers.

81 Barcelona are aimlessly moving the ball around.

79 Real Madrid's tough-tackling defender Pepe comes on instead of Ozil.

78 That win is likely to ease pressure on coach Jose Mourinho, whose side will face Barcelona again next weekend in the Spanish Laliga before taking on Manchester United in a crucial Champions League tie next week.

74 A night to forget for the Catalans, who are outplayed by their arch-rivals. Barcelona will have lots of work to do to regain their formidable form.

73 The third substitution for Barcelona, Xavi is replaced with Tiago.

72 Barcelona's Christiano Tello replaces the ineffective Pedro.

71 Real Madrid striker Gonzalo Higuain is replaced with Callejon.

Youngster Raphael Varane, who also scored in the first leg, towers above his markers to powerfully head home the third. Real Madrid have virtually ensured their win.


Barcelona are trying to break down a resilient defence, but in vain. They look a shadow of their old self.

63 Real Madrid are still very dangerous on the break. They can add to their tally.

60 Barcelona now need to score three goals to reach the final. That possibility is highly unlikely, given Real's superb display.

57 Cristiano Ronaldo scores again to leave Barcelona with an uphill to climb!! Angel Di Maria makes a darting run after a clearance by Sami Khedira, jinks into the area and superbly wrong-foots Puyol. His shot is parried by Pinto into the path of the Portuguese, who slots into an empty net.


Barca are clearly lacking imagination. Messi's trademark mazy runs are nowhere to be seen, and coach Jordi Roura is yet to make notable changes to his gameplan.

52 Successive shots from Barcelona are blocked by the defence. Busquets' subsequent effort is saved by Diego Lopez.

50 Real Madrid left back Coentrao wastes a chance to extend the gap!! He is released by a superb through pass on the right hand side of the penalty area but his weak shot is collected by Pinto.

48 Barcelona need to find the net to level the aggregate score but despite their domination of possession, Real still look the more likely side to double their lead.

The second half is underway

The referee blows his half-time whistle, Barcelona 0-1 Real Madrid

44 Real Madrid are producing a spirited defensive display that is reminiscent of Milan's battling performance.

41 Four minutes remaining before the end of the first half, which is very entertaining. The end-to-end game is so exciting.

40 Barcelona defender Carles Puyol receives a yellow card for a rash challenge on Ronaldo.

39 From the ensuing free-kick, Messi's curling low free-kick narrowly misses the target.

37 Real Madrid full back Alvaro Alberoa is booked for a foul on Andres Iniesta on the edge of the area.

36 At the other end, a powerful shot from Ronaldo from a difficult angle is palmed by Barca keeper Pinto.

35 Barcelona players are furious at the referee.

34 Another penalty claim by Barcelona is waved away by the referee. Winger Pedro appears to have been shoved by Xabi Alonso after jinking into the area.

30 Barcelona are still kept at bay by Real's tight defence. Their display so far resembles the one they produced in a surprising 2-0 Champions League defeat by AC Milan.

27 Iniesta cuts in from the right to fire a fierce drive just wide.

26 Barca are pouring forward en masse, leaving gaps at the back which Real can expose once again.

23 Ronaldo is causing Barcelona's backline all kinds of problems. Barca's defence is struggling to keep an eye on him.

21 Ronaldo, the match's liveliest performer so far, sends a long-range left-foot shot high over.

18 Real Madrid made the most of their counter-attacking abilities in the first quarter of an hour. Barcelona have the better possession but they are yet to penetrate the visitors' defence.

15 Barcelona have a penalty claim waved away by the referee after Fabregas goes down in the area. Tense moments now.

14 Portuguese wizard Cristiano Ronaldo sends keeper Pinto the wrong way to stun the Nou Camp crowd. Real Madrid take an early lead.


 Cristiano Ronaldo skips past Pique following a neatly-worked counter attack and the defender hauls him down.


Barcelona are relying on their trademark domination of possession to break down their opponents.

An angled Cesc Fabregas shot is handled by Real Madrid keeper Diego Lopez.

Barcelona make an explosive start  as they aim to take an early lead.

2 Lionel Messi almost breaks the deadlock!! Pedro feeds him inside the area after some superb individual effort but the Argentinean wizard's low shot from inside the area narrowly misses the target. Barcelona pile on pressure from the very beginning.

Andres Iniesta tries his luck from distance in Barca's first attempt. His long-range shot goes just wide.

The match is underway

Both sides are stepping onto the pitch amid a feverish atmosphere at the Nou Camp. Five minutes remaining before kick-off.

21:20 Real Madrid's starting line-up: Diego Lopez, Alvaro Arbeloa, Sergio Ramos, Raphael Varane, Coentrao, Xabi Alonso, Khedira, Di Maria, Ozil, Cristiano Ronaldo, Gonzalo Higuain.

21:10 Barcelona's starting line-up: Pinto, Dani Alves, Gerard Pique, Carles Puyol, Jordi Alba, Xavi, Sergio Busquets, Cesc Fabregas, Pedro, Lionel Messi, Andres Iniesta.
Field lineups

20:00 Both sides also meet in a largely meaningless Clasico in the Spanish league next weekend, where Real Madrid are expected to field a weakened side ahead of a far more important Champions League clash against Manchester United.
19:20 Barcelona's probable line-up: Pinto, Dani Alves, Gerard Pique, Carles Puyol, Jordi Alba, Xavi, Sergio Busquets, Cesc Fabregas, Pedro, Lionel Messi, Andres Iniesta.

 Real Madrid's probable line-up: Diego Lopez, Arbeloa, Sergio Ramos, Raphael Varane, Coentrao, Xabi Alonso, Khedira, Di Maria, Ozil, Cristiano Ronaldo, Gonzalo Higuain.

Treble-chasing Barcelona, who surprisingly lost 2-0 at AC Milan in last week's Champions League last 16 first-leg,  will need to improve their defence and attack after recent disappointing displays, according to assistant coach Jordi Roura.
18:30 Real Madrid are keen to avoid a Spanish Cup exit at the hands of their arch rivals after they virtually lost hopes of winning the Spanish league title. They only have the King's Cup and the Champions League to play for.
Stay tuned for Ahram Online's special live coverage of the clash between Real Madrid and Barcelona in the second leg of the Copa Del Rey semifinal on Tuesday at 20:00 GMT.
Cup holders Barca have a slight advantage ahead of Real's visit to the Nou Camp, which will be the 224th meeting between the arch rivals in all competitions, after they secured a 1-1 draw at the Bernabeu in last month's first leg

Real Madrid vs Barcelona: Ronaldo demolishes hosts to book Copa final berth - See more at:

Real Madrid vs Barcelona: Ronaldo demolishes hosts to book Copa final berthBarcelona: Real Madrid stormed into the Copa del Rey final in the most stunning manner possible, with an emphatic 3-1 victory over Barcelona at Camp Nou in the second leg of their last-four clash on Tuesday.

With a 1-1 home draw to overcome from the first leg, Jose Mourinho looked on in jubilation as his team executed their gameplan to perfection, frustrating the Catalans at the back, and through an inspirational Cristiano Ronaldo, giving a counter-attacking clinic up front. 

The Portuguese opened the scoring from the penalty spot 12 minutes in, becoming the first player to score in six successive Clasicos away from home, and finished off a surging break shortly before the hour mark to put Madrid in the driving seat. 

Raphael Varane put the finishing touches on an unbelievable night for the visitors when he headed home a corner, with Jordi Alba`s late goal coming as little consolation for the hosts.

Los Blancos now await either Sevilla or Atletico Madrid in the showpiece event on May 18. 
Sergio Busquets, Cesc Fabregas and Xavi returned to start in midfield for the hosts, with Carles Puyol partnering Gerard Pique in defence. For Madrid, Varane, the standout performer from the first leg, started alongside Sergio Ramos at centre-back.

Barca started positively, and with only two minutes on the clock, were nearly ahead. Pedro did brilliantly to turn Fabio Coentrao inside out and square for Lionel Messi, who narrowly missed the target from a tight angle.

But instead, it would be Madrid who would take the lead. Ronaldo was simply too quick for Pique, and was tripped up inside the area, leaving the referee with no choice but to award a penalty, from which the Portuguese forward slotted coolly into the bottom corner.

The Catalans exhibited their customary dominance of the ball, but Mourinho’s men were ready with discipline and numbers at the back, and a pacey threat on the counter whenever they won possession.

Referee Alberto Undiano Mallenco?, already the villain of the piece in the eyes of the Camp Nou faithful for the decision against Pique, was showered with further vitriol from the stands after correctly denying penalty appeals for Fabregas and Pedro.

And the home fans were left frustrated again moments before half-time, when Messi drilled a free kick agonisingly into the side netting, with half of the stadium already celebrating a goal.

The Blaugrana went close again minutes after the restart when Diego Lopez parried an effort by Busquets, with Alvaro Arbeloa taking the rebound off the toes of Fabregas from point blank range.

But much like the start of the first half, the chance was spurned, and again, Madrid would punish their profligacy on the counter-attack, this time putting the tie virtually out of reach.

Sami Khedira’s sublime first-time pass after winning the ball released Angel Di Maria against Puyol. The Barca captain was left on his backside by the skill of the winger, whose initial shot was parried by Jose Pinto, only for Ronaldo to bury the rebound. 

And with 22 minutes left, Madrid were in dreamland again, when Varane rose highest to head home Mesut Ozil’s corner in almost identical fashion to his goal in the first leg.

Flares were set off in the stands as a few home fans lost patience with events on the pitch, but their mood improved ever so slightly just before injury time when Alba ghosted in behind the full-back to slot Andres Iniesta`s clipped pass beyond Lopez. 

But the damage was long done by the irrepressible visitors, who will now contest the final in three months. The Clasico drama is not quite done, however, as both sides will lock horns at Santiago Bernabeu in la Liga on Saturday

Monday, February 4, 2013

Ten Real Madrid players selected for their national sides

Ten Real Madrid players selected for their national sides

Barcelona star defends Messi after Real Madrid car park scuffle

Barcelona news: Jordi Alba defends Lionel Messi after Real Madrid car park scuffle


Lionel Messi did not do 'anything wrong', according to Barcelona teammate Jordi Alba, after reports claimed the Argentine was involved in a car park scuffle with Real Madrid defender Alvaro Arbeloa following Wednesday's Clasico encounter.

According to Marca, Messi is alleged to have approached Arbeloa at the Santiago Bernabeu after Barcelona and Real Madrid had played out a 1-1 draw and launched a stunning tirade at the Spaniard.
Arbeloa's pregnant wife, who was also at the scene, was reported to have been shocked by the incident, which ended after Messi was dragged back to the Barcelona team bus by his club-mates.
Alba, however, has refuted claims that Messi was overly aggressive towards Arbeloa, and insists the Barcelona was simply frustrated after a testing meeting with Real Madrid.
"I didn't see anything wrong with the car park incident. Messi was just annoyed," Alba said, as reported by
Barcelona and Real Madrid will reignite their rivalry once again on February 27 as both clubs fight for a place in final of the Copa del Rey, with the scores even going into the last four second leg at the Camp Nou.
Cesc Fabregas had provided Barcelona with the lead in Madrid, before a goal from Raphael Varane ensured the tie was evenly poised going into the decider.


Chelsea star gets another snub from World champions

Chelsea news: Fernando Torres’ international future in the balance after latest snub Chelsea flop Fernando Torres has been left out of another Spain squad, while a number of other Premier League stars get the call up

Manager Vicente del Bosque has opted to go without Euro 2012’s top scorer in Torres, whose domestic form continues to be a source of frustration for Blues fans.
Chelsea are suffering from stuttering form in recent weeks under interim manager Rafael Benitez and the former Liverpool manager has not had the regenerative effect on the striker’s form as was hoped when he took over.
Comments from the Roja boss also suggested Torres would have to fight hard to get back into contention, as there was no mention of the £50million striker when questions were asked about the 21-man group.
Swansea City’s Michu had been pushing for a place and Del Bosque admitted he had been considered for selection, but opted against using him to avoid “experimentation” for the clash with Uruguay.
Torres’ Chelsea teammates Juan Mata and Cesar Azpilicueta were recalled to the squad, as were David Silva of Manchester City, Santi Cazorla of Arsenal and new Gunners signing Nacho Monreal.
‘El Niño’ has not played for the national team since coming on as a late substitute in the friendly against France last October.
Being overlooked again is the culmination of two years of indifferent form for the 28-year-old and his place in the starting line-up at Chelsea is also under threat since Demba Ba was signed from Newcastle United early in the January transfer window.
Spain will play Copa America champions Uruguay in the friendly match next Wednesday, which will be played at the Khalifa International Stadium in Doha, Qatar





Friday, February 1, 2013

New Features in PHP 5.4

New Features in PHP 5.4

by Rasmus Lerdorf

The LAMP stack has new competition, but features in this release have PHP pushing the envelope once again.
Published April 2012
Almost exactly eight years ago I wrote an article for the Oracle Technology Network called, “Do You PHP?”. In that article, I talked about PHP's stubborn, function-over-form approach to solving the "Web problem" and the fight to keep things simple. We were getting close to releasing PHP 5.0 at the time. Now here we are almost a decade later with a shiny new PHP 5.4.0 release, and while much has happened during that time, there are also many things that haven't changed at all.
One thing that hasn't changed is that the ecosystem is as important as it ever was. Solving the Web problem is about much more than choosing a scripting language. It is about the entire ecosystem around it. The LAMP stack has been strong for nearly 15 years now and it is still popular, but we are starting to see strong alternatives. PHP-FPM with nginx has been gaining popularity rapidly because of the much improved support starting in PHP 5.3 and further streamlined in 5.4. The M, or database, part of the stack is also starting to become much more diverse than it was 8 years ago. The various NoSQL solutions and MySQL Cluster provide a richer set of options than just throwing everything into a MyISAM table.
A number of interesting technologies have appeared and PHP extensions have been written to make them easily accessible. One of my favorites is libevent, which you can use to write high-performance event-driven applications in PHP. Another is ZeroMQ, which is a high-level socket library. Much like SQLite removed any and all need to ever write another raw file format and associated parser, ZeroMQ has removed any reason to play around with socket protocols and associated socket handling code. You can even combine libevent with ZeroMQ for an awesome, high-performance, standalone event-driven server. (See this example if you are interested in that.) I also really like SVM (Support Vector Machine), a machine-learning algorithm that you can throw a lot of problems at without needing to become a machine-learning geek.
There are also a number of extensions that have become well-established over the last couple of years. Gearman, in particular, has become popular and shows up as part of the common stack people deploy. Gearman lets you dispatch jobs to be done by workers asynchronously. The workers can be spread out over many servers and they can even further dispatch more jobs MapReduce-style.
After the release of PHP 5.0 in 2004, 5.1 followed in 2005 with the new DateTime implementation, PDO, and performance improvements. PHP 5.2 came in 2006 and brought an improved memory manager, JSON support, and input filtering. At that point we started the push to PHP 6, which was a super-ambitious plan to completely rewrite everything around the ICU (International Components for Unicode) library. It turned out to be a little too ambitious - we couldn't get enough developers excited about it, and instead ended up rolling all the various features that had been sitting around waiting for PHP 6 into a PHP 5.3 release in 2009. This 3-year gap between 5.2 and 5.3 also meant that 5.3 brought a lot of new things to PHP: namespaces, late static binding, closures, garbage collection, restricted goto, mysqlnd (MySQL native driver), much better Windows performance, and many other things.
In hindsight, it probably would have made sense to call this release PHP 6, but PHP 6 had become synonymous with the Unicode effort to the point that books had even been written about it, so we didn't feel we could release PHP 6 without a major push toward Unicode. We did introduce an ICU extension called “intl” that also compiles against PHP 5.2, which gives you access to much of ICU's functionality. The mbstring extension has improved steadily over time, which means that pretty much any Unicode-related problem has a solution, it just isn't cleanly integrated into the language itself.
This brings us to the PHP 5.4 release in 2012. Again, an almost 3-year gap between releases, which is something we want to improve upon. I would like to get back to annual releases with fewer new features in each.
Here are the major features you will see when you upgrade to 5.4:

Memory and Performance Improvements

A number of internal structures have been made smaller or eliminated entirely, which has resulted in 20-50% memory savings in large PHP applications. And performance is up by 10-30% (heavily dependent on what your code is doing) through a number of optimizations including inlining various common code-paths, $GLOBALS has been added to the JIT, the ‘@’ operator is faster, run-time class/function/constant caches have been added, run-time string constants are now interned, constant access is faster through pre-computed hashes, empty arrays are quicker and consume less memory, unserialize() and FastCGI request handling is faster, plus many more memory and performance tweaks were made throughout the code.
Some early test have shown that Zend Framework runs 21% faster and uses 23% less memory under 5.4, for example, and Drupal uses 50% less memory and runs about 7% faster.


Traits is probably the most talked about new feature in PHP 5.4 - think of them as compiler-assisted copy-and-paste. Traits are a feature of Scala as well. Other languages may refer to them as "mixins" - or they may not name them at all but have an extended interface mechanism that allows the interface to contain an actual implementation of its methods.
In contrast to mixins, traits in PHP include explicit conflict resolution if multiple traits implement the same methods.

trait Singleton {
    public static function getInstance() { ... }

class A {
    use Singleton;
    // ...

class B extends ArrayObject {
    use Singleton;
    // ...

// Singleton method is now available for both classes

See for many more examples including the conflict resolution syntax, method precedence, visibility, and support for constants and properties in traits. Also, for more of the theory behind the concept, you can read Nathan Schärli’s dissertation, “Traits: Composing Classes from Behavioral Building Blocks.”

Short Array Syntax

A simple, but very popular syntax addition:
$a = [1, 2, 3];
$b = ['foo' => 'orange', 'bar' => 'apple'];

That is, you now no longer need to use the ‘array’ keyword to define an array.

Function Array De-referencing

Another oft-requested syntax addition. Function calls that return an array can now be de-referenced directly:
function fruits() {
    return ['apple', 'banana', 'orange'];
echo fruits()[0]; // Outputs: apple

Instance Method Call

Related to function array dereferencing, you can now call a method on object instantiation. And as in previous versions, you can of course still chain method calls, so you can now write code like this:
class foo {
    public $x = 1;

    public function getX() {
        return $this->x;
    public function setX($val) {
        $this->x = $val;
        return $this;

$X = (new foo)->setX(20)->getX();
echo $X; // 20

Although, unless your constructor is doing something useful, since the instantiated object is thrown away perhaps you should be using a static method call here instead. If we combine it with the short array syntax and function array de-referencing we can write some really convoluted code:
class foo extends ArrayObject {
    public function __construct($arr) {

echo (new foo( [1, [4, 5], 3] ))[1][0];

At a glance, can you tell what the output will be? Here we pass a two-dimensional array to the constructor, which just returns the array. We then pick out the first element of the second dimension, so this would output “4”.

Closure Binding

Closures were introduced in PHP 5.3, but in 5.4 we have refined how they interact with objects. For example:
class Foo {
  private $prop;
  function __construct($prop) {
    $this->prop = $prop;
  public function getPrinter() {
    return function() { echo ucfirst($this->prop); };

$a = new Foo('bar');;
$func = $a->getPrinter();
$func(); // Outputs: Bar

Note that the closure accesses $this->prop, which is a private property. By default, closures in PHP use early-binding - which means that variables inside the closure will have the value they had when the closure was defined. This can be switched to late-binding by using references. However, closures may also be re-bound:
$a = new Foo('bar');
$b = new Foo('pickle');
$func = $a->getPrinter();
$func(); // Outputs: Bar
$func = $func->bindTo($b);
$func(); // Outputs: Pickle

Here we have re-bound the closure from the $a instance to the instance in $b. If you don’t want your closure to ever have access to the object instance, you can declare it static:
class Foo {
  private $prop;
  function __construct($prop) {
    $this->prop = $prop;
  public function getPrinter() {
    return static function() { echo ucfirst($this->prop); };

$a = new Foo('bar');;
$func = $a->getPrinter();
$func(); // Fatal error: Using $this when not in object context

Objects as Functions

There is a new magic method called “__invoke” which can be used like this:
class MoneyObject {
    private $value;
    function __construct($val) {
        $this->value = $val;
    function __invoke() {
        return sprintf('$%.2f',$this->value);
$Money = new MoneyObject(11.02/5*13);
echo $Money(); // Outputs: $28.65

Built-in Web Server (CLI)

The CLI server is a tiny Web server implementation that you can run from the command line:
% php -S localhost:8000
PHP 5.4.0 Development Server started at Sun Mar 11 13:27:09 2012
Listening on localhost:8080
Document root is /home/rasmus
Press Ctrl-C to quit.

CLI Server is not intended for use as a production Web server; we are going to be using it for running some of our PHP regression tests and I can see other unit testing mechanisms and probably IDEs also making use of it. It does have some really useful features for day-to-day debugging of your code from the command line. By default it uses the current directory as the DocumentRoot; it handles static file requests as well. The default directory index file is “index.php” so you can fire it up in a directory full of .php, .css, .jpg, etc. file and it will just work. For more complex applications that might use mod_rewrite to send all requests to a front-controller or router, you can wrap that router with a simple little script and start the CLI Server like this:
% php -S localhost:8080 /path/to/router.php
PHP 5.4.0 Development Server started at Sun Mar 11 13:28:01 2012
Listening on localhost:8080
Document root is /tmp/web
Press Ctrl-C to quit.

The router.php script might look like this:
if (preg_match('!\.php$!', $_SERVER["REQUEST_URI"])) {
    require basename($_SERVER["REQUEST_URI"]);
} else if (strpos($_SERVER["REQUEST_URI"], '.')) {
    return false; // serve the requested file as-is.
} else {

This wrapper loads up direct .php requests, passes any other requests that contain a “.” through to the static file handler and everything else gets passed to the framework’s router. You can run Drupal and Symphony directly from the command line like this.

Native Session Handler Interface

As a small convenience feature, there is now a session handler interface you can implement. Now you can just pass an instance of your session handling object to session_set_save_handler() instead of having to pass it six ugly function names:
SessionHandler implements SessionHandlerInterface {
  public int close ( void )
  public int destroy ( string $sessionid )
  public int gc ( int $maxlifetime )
  public int open ( string $save_path , string $sessionid )
  public string read ( string $sessionid )
  public int write ( string $sessionid , string $sessiondata )
session_set_save_handler(new MySessionHandler);

JsonSerializable Interface

You can now control what happens if someone tries to json_encode() your object by implementing the JsonSerializable interface:
class Foo implements JsonSerializable {
    private $data = 'Bar';
    public function jsonSerialize() {
        return array('data'=>$this->data);
echo json_encode(new Foo); // Outputs: {"data":"Bar"}

Binary Notation

To go along with PHP’s native support for hexadecimal and octal there is now also binary notation:
$mask = 0b010101;

Improved Error Messages

Error messages are slightly improved.
% php -r 'class abc foo' 
Parse error: syntax error, unexpected T_STRING, expecting '{' 
in Command line code on line 1

% php -r 'class abc foo'
Parse error: syntax error, unexpected 'foo' (T_STRING), expecting '{' 
in Command line code on line

Perhaps somewhat subtle, but the difference is the value of the stray token “foo” is shown in the error message now.

Array to String Conversion Notice

If you have ever used PHP you have probably ended up with the word “Array” randomly appearing in your page because you tried to output an array directly. Whenever an array is directly converted to a string, chances are it is a bug and there is now a notice for that:
$a = [1,2,3];
echo $a;

Note: Array to string conversion in example.php onlLine 2

Removed Features

We finally pulled the trigger on a number of features that have been marked as deprecated for years. These include allow_call_time_pass_reference, define_syslog_variables,, register_globals, register_long_arrays, magic_quotes, safe_mode, zend.ze1_compatibility_mode, session.bug_compat42, session.bug_compat_warn and y2k_compliance.
Out of these magic_quotes is probably the biggest risk. Despite all the things that are wrong with magic_quotes, naively-written applications that don’t do anything to protect themselves from SQL injection are protected by magic_quotes in previous versions. Upgrading to PHP 5.4 without verifying that proper SQLi-protection measures have been taken could lead to security vulnerabilities.

Other Changes and Features

  • There is a new “callable” typehint for when a method takes a callback as an argument.
  • htmlspecialchars() and htmlentities() now have better support for Asian characters and they default to UTF-8 instead of ISO-8859-1 if the PHP default_charset isn’t explicitly set in the php.ini file.
  • <?= (the short echo syntax) is now always available regardless of the value of the short_tags ini setting. This should make templating system authors happy.
  • Session ids are now generated with entropy from /dev/urandom (or equivalent) by default instead of being an option you explicitly have to enable, as in previous versions.
  • mysqlnd, the bundled MySQL Native Driver library, is now used by default for the various extensions that talk to MySQL unless explicitly overridden through ./configure at compile-time.
There are probably another 100 small changes and features. An upgrade from PHP 5.3 to 5.4 should be extremely smooth, but read the migration guide to make sure. If you are upgrading from an earlier version you likely have a bit more work to do. Check the previous migration guides to get started.

What's Next for PHP?

We don’t have a long term roadmap for PHP. PHP moves with the Web. We don’t know what will be the important Web trends and technologies in 5-10 years, but we do know that PHP will be there with our take on how to approach them.

In the shorter term we discuss PHP development on the “internals” mailing list and as consensus starts to form around a large feature it evolves to an RFC. You can find the RFCs at Once a good set of new features have been voted on and properly implemented and tested, we start down the path toward a new release.

PHP has grown and evolved along with the Web and has kept a steady market share of approximately a third of all the Web sites in the world. This includes not only some of the biggest names on the Web, but also a large percentage of the smallest. It is that latter fact that sets PHP apart for me: Scaling up is a natural and even expected characteristic and one that appeals strongly to engineers, but scaling down is less natural and in some cases harder. When you strike the right balance and achieve both in the same codebase allowing dorm room hacks to grow to billion-dollar companies, then you really have something.