Domanda

Environment: Windows Server 2012 running Parallel's Plesk v11.5.30 Update #25, last updated at Dec 6, 2013 01:58 AM.

I have a PHP script, which works on PHP version 5.2.17, however I get a 500 server error on one section of code, when I switch to PHP version 5.3.27.

I am using the proper syntax at the top of the header include, first item of script, to display errors but that does not work.

ini_set('display_errors', 'On');
error_reporting(E_ALL);

Here is the offending code:

MyScript.php

<?php
     // Include PHP scripts.
     include_once( "../Scripts/Header.php" );
     ...

Header.php

<?php
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
    ...
    include_once("myPeople.php");
    include_once("Tools.php");
    ...

Tools.php (function fragment)

// Create the needed objects.
$oPeople = new myPeople($IdPerson);

// Handle the request.
$oPeople->IsVerified($IdPerson, &$IdVerified);

The IsVerified() method trips things. What is weird is that I am only including the file, not executing it. I tried commenting out the function and just having an empty function, but that did not help. The only thing that helps is to comment out the line.

function IsVerified($IdPerson, &$IdVerified)
{
}

So my questions are:

  1. What changed in PHP version 5.3.17 (and later versions, as I tried 5.4.16 and same issue) that causes the script to trip?
  2. Why can I no longer see any error message, even though I am enabling error messages?
È stato utile?

Soluzione

It's because you are passing by reference at runtime. This generated a waringn in previous versions of PHP and since PHP 5.4 it is a fatal error. Check this example: http://3v4l.org/dQWEt

You need to change this line:

$oPeople->IsVerified($IdPerson, &$IdVerified);

to:

$oPeople->IsVerified($IdPerson, $IdVerified);

You should fix this of course because it will be a fatal error after next upgrade but however, you are just upgrading to 5.3 and this should therefore not lead to a fatal error. Do you have registered a custom error handler using set_error_handler() ? This could be the reason why you aren't see any error messages and the deprecated message leads to HTTP 500 responses.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top