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.
Related
When I try to install Jetpack on my Wordpress website I get the following error:
Error Details: The Jetpack server could not communicate with your
site’s XML-RPC URL. Please check to make sure example.com/xmlrpc.php
is working properly. It should show ‘XML‑RPC server accepts POST
requests only.’ on a line by itself when viewed in a browser and
should not have any blank lines or extra output anywhere.
When I goto the URL I see this:
XML‑RPC server accepts POST requests only.
Which is expected. It feels like I have tried everything I have googled and everything here:
https://jetpack.com/support/getting-started-with-jetpack/what-do-these-error-messages-mean/blank-lines-xmlrpc/
I have tried uninstalling all plugins and still does not work :(
What am I doing wrong?
Please help!
Looking at the link, they specifically mention whitespace or output that could be causing issues, and ask you to check there isn't any before the opening PHP tags etc.
The reason they talk about this is because if there has been any output at all, then PHP will no longer be able to send any HTTP headers!
If your files look ok, then I guess (guarantee even?) that your display_errors is turned on. Depending on the level of error_reporting in your ini file, any little notice or warning will create output, and therefore stop any further HTTP headers from being set.
For the best error logging experience (and hopefully to also fix your error), set error_reporting to -1, turn display_errors off, and set a custom error_log. Then in the terminal, type tail -f /path/to/error_log. Your notices, warnings and errors will now scroll past in real time, without distorting your web page's display.
Fatal error: Can't use function return value in write on line 3
I've looked extensively for an answer to my specific situation with no progress. Please review what I've already tried and I've included my VPS global php.ini file. No php.ini files exist within the website root.
<?php
session_start();
?>
<!DOCTYPE html>
<html>
I have no idea how that's possible. Please check out what I've already done to try to solve the problem.
Problem originated when I was unable to pass variables to another page using
$_SESSION['$example'] variables with no luck. But I'll worry about that next.
VPS System Specs Currently (Servers/Networks Are Not My Strong Area)
Apache 3 on CentOS 6.8
Default PHP Version | 5
PHP 5 Handler | suPHP
Apache suEXEC | off
Apache Ruid2 | off
Default PHP Version (.php files) | 5
PHP 5 Handler | suPHP
Attempted Solutions
Disabled .htaccess
.htaccess contains
***suPHP_ConfigPath /***
Header append Vary User-Agent
Prior to disabling:
Removed All 301 Rewrite Rules as I've read they interfere with
sessions
Disabled Error Documents
Ensure No Whitespaces Following session_start();
Caching
Turned off all caching through WHM (that I'm aware of)
Tested both Firefox and Chrome before and after clearing history/cookies/cache/etc
Deleted CloudFlare service for this domain
Additional Information
I Don't have a php.ini file since I use a VPS (in case anyone was wondering)
I use php on almost every other page.
Here is an example of the first few lines of another page.
<?php
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
//Version 1.75
The above code is just the first few lines but the page executes fine without issue. It should be noted that this is a redirect page following a PayPal payment to my website. This issue is recent and previously it has worked fine.
It should also be noted that I use session_write_close(): session_unset(); and session_destroy(); on appropriate pages to unset all $_SESSION variables and terminate sessions.
Below is a link to the php.ini file as text if that helps. The domain contained in the link is not the domain with the issue. I'm not attempting to be "shifty" about the domain with the issue, I just don't want people using the service when it's not working properly.
Global PHP INI File As Text Document
Anyone who solves this, I owe you!
-Andrew
Solved Accidentally
I solved the issues, but still don't know what was causing the Fatal Error
Fatal error: Can't use function return value in write on line 3
$_SESSION variables didn't pass between pages.
I solved both the Fatal Error issue and the $_SESSION variables problem by doing one thing. For some, this may be standard procedure, but I am self-taught and this did not occur to me. I was making changes to the PHP advanced configuration in WHM and never did not see any changes as a result.
I was banging my head against the wall for two days trying every solution I read in the forums.
Apache Server Restart
I never restarted my Apache Server during this time, both issues were resolved.
While this solution may seem rudimentary or common practice for some, it's easy to overlook. I read at least 30 different forum posts on Stack Overflow and other sites. Not one suggested an Apache Restart as a method to check.
PHP Configuration
I changed my PHP configuration as listed below and my sessions variables were passing.
session.use_cookies = 1
session.use_only_cookies = 1
session.use_trans_sid = 0
Thank you for everyone who took the time to look at this.
Sincerely, Andrew
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
I have a staging server running a Yii application that now gives a 'white screen of death'. I cannot see anything being ouputted to the screen (or even the source code when 'view source'), locally the same code runs without any issues.
Can anyone suggest a good routine to debug 'white screen of death' within a Yii application?
Getting a blank screen in yii is mostly because error_reporting is off.
Put
error_reporting(-1);
ini_set('display_errors', true);
in index.php should get your output back.
Note that you can always look in application.log and apaches error.log for informations when you don't have some output.
This is for Yii2
I found the code was failing in vendor/yiisoft/yii2/BaseYii.php at method autoload($className). It was failing at execution:
include $classFile; (line 293)
The cause in my case was a function method name declared twice.
You might be interested to know that you can discover the cause (which Yii2 suppresses through its own error-handling) by preceding the command with Chris's recommended code above https://stackoverflow.com/a/25139283/3125602. If you introduce them too early in the code, they get overwritten by Yii2's error-handling settings.
It is quite a simple issue and happens either when a script reaches the PHP memory limit or during a plugin or theme conflict.
Solutions :
Increase the Memory Limit :
Since this is regarded as one of the cause, it is recommended that the PHP memory limit be increased. Edit your wp-config.php file via FTP adding the following line of code:
define( ‘WP_MEMORY_LIMIT’, ‘64’);
This increases your memory limit to 64M. You might need to contact your host before you do it as some host don’t allow it from your end.
Deactivate all your Plugins :
Connect to your site via FTP and rename the wp-content/plugins folder to plugins_old to deactivate all your plugins.
Here is a detailed answer to the infamous "White Screen of Death" problem. Thank me later :)
https://www.perceptionsystem.com/blog/wordpress-errors-solution/
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.