0

I was given the task to upload a script on some old production server and, as expected, many things don't work.

I wanted to know if it was possible to turn on error reporting for a single script without having access to the actual php.ini file.

I've tried this: PHP production server - turn on error messages, using:

ini_set('display_errors', 'On');
ini_set('display_errors', 1);
ini_set('display_errors', '1');

But that won't work on this server. If I trigger an error, e.g.:

public static funtion myfunc() { … }

Or I try to use an undefined function, e.g.:

password_verify();

I end up staring at a blank screen. I also don't have access to any (useful) logs. I've also tried this: How to get useful error messages in PHP?, but I don't have access to any .htaccess file either.

Is there another way to enable this feature? Or is it possible to catch critical errors and display their information, programatically? The server's PHP version is 5.3 (5.3.28).

Community
  • 1
  • 1
arielnmz
  • 8,354
  • 9
  • 38
  • 66

3 Answers3

1

From your posted link, do you have try to change

ini_set('display_errors', 'On');

with

ini_set('display_errors', 1)

Cheers

Community
  • 1
  • 1
  • Yes, I tried that instead of 'On' before, but that doesn't work either. It's in fact commented above it, it's the first one I tried. – arielnmz Jul 09 '14 at 15:37
1

An old question, but I stumbled across this problem on a client's server when the guy in charge of Apache was on a very different timezone and I didn't want to wait 8 hours. If you put your code in a try catch block, like so:

try {
   //your test code here
}
catch (Exception $e)
{
   echo $e->getMessage();
}

That should solve a lot of your problems.

Fibericon
  • 5,684
  • 12
  • 37
  • 64
0

You might be out of luck if the server has display_errors configured in the apache config with a 'php_admin_value' flag. That prevents override with a htaccess or ini_set functions. http://www.php.net/manual/en/configuration.changes.php

You might be able to grab the error with your own error handler function using set_error_handler, but it has some limitations too. It can can only grab warnings and user defined errors. http://www.php.net/manual/en/function.set-error-handler.php

txyoji
  • 6,680
  • 1
  • 44
  • 46