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