changing log_errors_max_len has no effect - php

I'm not experienced in PHP and I had problems logging out big arrays using error_log and print_r.
I was told here to change the log_errors_max_len of the php.ini file and I went ahead and did a <?php phpinfo(); ?> to see where the php.ini file was loaded from. Then I changed it to log_errors_max_len = 0 but still the output is truncated.
I'm also using Laravel.
Anybody has any idea why this is not working? (I already restarted apache :)

The main thing here, is that log_errors_max_len seems pretty useless in this situation. PHP manual states that:
This length is applied to logged errors, displayed errors and also to
$php_errormsg, but not to explicitly called functions such as
error_log()
The only solution I was able to find so far is to use:
error_log("Long error message...", 3, CUSTOM_LOG_FILE);
The second parameter of error_log() allows you to redirect message to a custom file. So, the last parameter should be a path to a custom log file.
This way I'm getting full error message and, what might be more important for someone, non ASCII characters are clearly readable there (not sure though, might be my bad, but when I'm logging them with standard log file - I get things like \xd0\xbf).

Make sure to set the configuration at the top of your page like this.
<?php
ini_set("log_errors_max_len", 0);
?>
See also this question. Might it be the issue you have?

My mistake was, I mixed up php script arguments and php interpreter arguments. This happened in an IDE, but could as well happen in command line.
Two different things:
php -d log_errors_max_len=0 index.php // Interpreter arguments
php index.php -d log_errors_max_len=0 // Script arguments

Related

I've turned display_errors to On but I don't see any errors on the webpages

I'm trying to see what error PHP is producing. So I've changed the value of dispaly_errors to ON in the etc/php5/apache2/php.ini file.
The file doesn't display anything and I don't see any error on the webpages.
Am I missing any thing?
First, you have to make sure that this is your correct ini file. Usually the file you have used is the correct one. If not sure, you can create a simple PHP program to call the phpinfo() function and check this out.
Next, you have to restart Apache. Without a restart your settings don't take effect.
Another thing... This file can be a little misleading because there are so many comments in it. The actual line to change is way down. On my setup (LAMP/Ubuntu) the setting is on line 538.
Open php.ini file from your php folder, remove semicolon from all error reporting like
;error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT, ;display_errors=On etc, at last, restart your server, you will find all error messages.
Another way for showing error, you can write these codes in your script -
echo '<pre>';
error_reporting(E_ALL);
ini_set('display_errors', 1);
In addition to enabling display_errors, you may also need to set the error reporting level. if you are expecting errors with a script that is redirecting, be sure to turn off the redirection or you may never see them.

Fatal PHP Errors in IIS 7.5

I'd like to see any PHP errors that are occuring, ie the "Expected ; on line 5 of myfile.php" sort of thing. Unfortunately, I cannot seem to figure out how to see this information.
I've set E_ALL, display_errors ON, friendly error messages are turned off, IIS is set to pass-through on errors, what am I missing?
Syntax errors used to show up as stated above on any page; they no longer do. We moved the server to a localhost for development, and I guess didn't mimic exactly the server config. Now I'm stumped.
Tried on IE and Chrome, neither of which show the errors.
Errors are logged in PHP's log file, but I'd still like them to be displayed on the page; at least for now.
UPDATE:
Just tried adding ini_set('display_errors', 'on'); directly into the requested page, and it now works.. but why? Why does it need to be set locally? My PHP.ini file has this declared already.
To answer the first part of the question; to see the errors when using ajax: You can use the developer tools of your browser to see the exact response from the server.
In FireBug for Firefox for example, you go to the Net tab and there you see all ajax request popping up as they happen. Opening one of these requests will give you an overview with more tabs like Response and HTML.
Try using:
error_reporting (-1);
E_ALL isn't really "all" for php < 5.4.
Also, make sure 'display_errors' is set.
ini_set( 'display_errors', 1 );
Well, looks like this is half my own stupidity, half the cloudiness of automatic installations.
Turns out there were TWO php.ini files, and that IIS used the one located within the iis express directory on the main drive, instead of the regular PHP directory.
So to anybody else having this problem, I'm providing the full list of crap you have to wade through to get the errors as you would like:
1) Turn off the IIS default error pages
2) Disable 'friendly error messages'
3) Ensure you are using the CORRECT php.ini file, and change the parameters as needed. Specifically error_reporting and display_errors.
All of this is necessary before seeing all of the error messages you need right in the browser.

Php script stops after long time and no error could be found on the error_log

Im running a long php script which handles large amounts of data.
The problem is that the script suddenly stops and no exception is thrown or could be found on the error_log.
I have set the display_errors and the error_logging to 1 in the .ini config file.
Few more details:
1) The scripts executes the 'file_get_contents' function for many times.
2) The scripts contains recursion when the file_get_contents fails.
Any help would be appriciated.
It might have hit the max execution time.
set_time_limit(0); // to increase the timelimit to infinity
Error loging configs are different depending on your hosting environment. I'd first verify that you're editing the right php.ini file. Take a look at your phpinfo output and make sure that those params are indeed set and check the path/file for where errors are being logged to. Sometimes it goes to the apache error log, other times it can be sent to a dedicated php log. Are you able to get any error output if you purposefully create a syntax error? You might also consider looking in your syslog to see if there's anything there.

using stream wrappers in php gives blank page

I am implementing a template system using the wrapper class in this example: http://www.php.net/manual/en/stream.streamwrapper.example-1.php
I use this code to get the wrapper output:
ob_start();
include("template://" . $template_name);
$template .= ob_get_contents();
ob_end_clean();
However, in some servers this code is not working, all I get is a blank page. I am not sure if it is a php directive issue, I changed allow_url_include to both 0 and 1, but it did not have any effects on the code.
So what is the problem with the code.
EDIT: error logging is on, and it is not showing any errors related to this issue
in some servers this code is not working
In all likelihood, this is because php streams are not available or configured properly on these servers. It die with an error, and you don't see the error because of the output buffer
My host updated to Litespeed and a more stringent Suhosin setup. At first I thought it was Litespeed, but it was indeed Suhosin (I twigged from this thread, thanks!).
It's just a php.ini setting you need to change, you have to add your stream name to the include whitelist:
suhosin.executor.include.whitelist = template://
And then it'll work fine again. Here's a couple more links saying the same:
A bigger example: http://cweiske.de/tagebuch/suhosin-phar.htm
-Others struggling with the same: http://forum.bytesforall.com/showthread.php?t=12262&page=2
Suhosin doco (doesn't really explain with huge detail) search for: suhosin.executor.include.whitelist
I had the same issue and found that PHP Suhosin was causing this 'white screen of death'.
That could explain why this works on some servers and not on others.
There could be a Suhosin config option for dealing with that, check out the website: http://www.hardened-php.net/suhosin/
tl;dr I ended up removing Suhosin which resolved the issue.

Xampp. Php script displays a blank page!

The php script is calling four functions that scrape different websites for data.
$returnData[0]=getWebsite1Data($description);
$returnData[1]=getWebsite2Data($description);
$returnData[2]=getWebsite3Data($description);
$returnData[3]=getWebsite4Data($description);
The script displays the web-page correctly if I disable the call to any one random function.
That makes me think its a resource problem. If it is a resource problem how do I correct it in Xampp. I've tried unsetting the variables but that didn't work either.
Make sure Error Reporting is set high enough in php.ini
Check your phpinfo and see what your "memory_limit" is. Try doubling it in your php.ini.

Categories