function - invoking php methods directly -


this question has answer here:

why work:

$n = explode("@", "some@email.com"); echo $n[0]; 

and not work?

explode("@", "some@email.com")[0] 

when try latter, get:

parse error: syntax error, unexpected '[' 

it works in later versions of php (>= 5.4.0):

php 5.4.0 offers wide range of new features:

[...] - function array dereferencing has been added, e.g. foo()[0]. [...]

older versions of php not support function array dereferencing, why syntax error (php not know [, tells "unexpected").


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c# - Avoiding duplicate methods for Task and Task<T> -

javascript - Which segment of a polyline was clicked? -