0

so I'm working on this theme on my localhost, and I just uploaded it to see if it'd work and I'm getting a weird parse error for these lines in my functions.php file. It works fine on my localhost though:

$next = isset($_POST['next']) ? $_POST['next'] : false;
$prev = isset($_POST['prev']) ? $_POST['prev'] : false;

$nexp = explode('=', explode('?', $next)[1])[1];
$pexp = explode('=', explode('?', $prev)[1])[1];

It says, unexpected '[' on the line starting with $nexp and $pexp. I'm a bit confused (and tired), and I don't really see what the problem with this line is, and why it would work on localhost but not on the server.

Any help would be appreciated.

1 Answer 1

0

Array dereference (accessing array item directly after function result) is only possible since PHP 5.4, I'm guessing your remote server is running a lower version.

Just use:

$varname_temp = explode( 'stuff' );
$varname = $varname_temp[1];

Also on a side note, it's always best to set your local to use the same PHP version as your remote server.

Kat

2
  • I thought it was something like this. Thanks so much, I really need to stay more up to date with PHP development.
    – Johnny
    Commented Jul 28, 2014 at 17:42
  • No worries, I find it annoying too that shared hosting providers still have not updated their PHP versions. Grrr.. :)
    – Katrina
    Commented Jul 29, 2014 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.