-2

Why My Script Not Work In Local USbwebserver

Parse error: syntax error, unexpected '[' in F:\Danyial\USBWebserver v8.5\root\supportify\test.php on line 4

And Its Working On MY Server Side

<?php

//why its not work
if(mysql_fetch_array(mysql_query("select count(*) from gatwaylog"))[0]==0){
    echo 'hi';
}

//and why it work
$data=mysql_fetch_array(mysql_query("select count(*) from gatwaylog"));
if($data[0]==0){
    echo 'hi';
}

?>
Nilesh Thakkar
  • 1,442
  • 4
  • 25
  • 36

1 Answers1

2

Array dereferencing isn't supported in php version <= 5.3 (*)

As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.

As of PHP 5.5 it is possible to array dereference an array literal.

Harshit
  • 5,147
  • 9
  • 46
  • 93