Tag Archives: syntax

Adding new php syntax

This is a quick patch I did to php's source code to implement some special syntax. Basically I wanted to be able to define an array like this:

  1. $a=[ 1,2,3,4];

Get the patch here:  [download#5]
To get this behavior download php's source code, extract it put my patch in the source directory and  do this:

  1.  

( This will only compile but not install - in case you want that just type make install at the end )
And here's a test script :

  1. $a=[ 'key' => 'value'

Save this script as test.php then run sapi/cli/php test.php

This was tested on php 5.2.6 and 5.2.9. I think this is probably useless for most people but it was fun to write so why not share it 🙂