Is there a PHP parameter that sets whether it is possible to index the result of a function?

I have two servers. They both run php 5.3.3. This code runs on one server and returns a syntax error from another. Is there a php ini setting that affects this behavior? I cannot find anything related in the PHP documentation, but I can search in the wrong place.

Server 1

> php -v PHP 5.3.3 (cli) (built: Sep 23 2010 14:15:16) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans php > echo explode(" ", " foo ")[1]; foo 

Server 2

 > php -v PHP 5.3.3 (cli) (built: Jan 31 2011 15:57:29) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies php > echo explode(" ", " foo ")[1]; Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1 

Another idea: PHP on both servers is compiled to order, so it can also be a different compilation flag.

+8
php xdebug configuration
source share
2 answers

Yeah! I get it.

We installed Facebook XHP to profile our development server. This syntax (which is pretty elegant) has been added in the PHP module. Here's the diff of the php.ini file between servers 1 and 2:

 > ; XHP https://github.com/facebook/xhp/wiki/Building-XHP > extension=xhp.so > ; adds support for the [] operator on the return value of a function > xhp.idx_expr = 1 > ; Tracking errors in XHP applications is very difficult without annotations. > xhp.include_debug = 1 

I like this syntax, so I will probably install XHP on another server. Thank you for helping Michas for inviting me to split ini files.

+3
source share

Not.

PHP does not support this syntax. It is on the trunk , but not yet released (as from PHP 5.3.3).

I have no idea how this works on your first server, but maybe this "Xdebug" matters?

+3
source share

All Articles