PHP5.3 + IIS 7 + FastCGI - Parse error when using an array from a function [duplicate]

StackOverflow https://stackoverflow.com/questions/23310696

  •  09-07-2023
  •  | 
  •  

Вопрос

First time in a long time since I've used PHP with IIS, however I've hit a bit of a deadlock when it comes to this line

if($this->debug) var_dump($this->_handle->error . " L" . debug_backtrace()[0]["line"]);

On my Debian development box - this will work perfectly (albeit not the best coding style in the world)

However on the Server 2008 R2 box with PHP5.3 + IIS 7 + FastCGI running, it will throw a parse error Parse error: syntax error, unexpected '[' in C:\inetpub\linkfinder\dev\dbhandler.php on line 94

My PHP.ini similar between the two boxes through running a diff against them.

I will be also modifying the code today across the project to move away from this coding style but I was interested in if it is this a common limitation of PHP in IIS or am I missing a config setting?

Это было полезно?

Решение

You are trying to do function array dereferencing which is the latest feature(s) of PHP 5.4 and not available on PHP 5.3.

You need to rewrite like this for that to work..

<?php
if($this->debug) {
   $backtrace = debug_backtrace();
   var_dump($this->_handle->error . " L" . $backtrace[0]["line"]);
}
?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top