Blank page on PHP (7.3.9) using Xampp 3.2.4 - php

So I am using xampp as my server hosting, and haven't got a problem in years. But I found something strange happening.
I have this code:
require "init.php";
require_once('vendor/autoload.php');
$pdf = new TCPDF("P", "mm", 'A4', true, 'UTF-8', false);
var_dump($pdf);
If I execute this code. My page is fully blank? And sometimes it isn't. Like so:
But when I execute my page in a command line, like so:
c:\xampp\php\php.exe C:\xampp\htdocs\websites\Traject-Parket\index.php
I get the var_dump I wrote.
So I have no errors whats so ever? How come my page is blank and sometimes isn't? Because in this project nothing seems to work but in other projects it does.

Blank pages (or WSOD, white screen of death) is when your script fails.
You don;'t have display_errors turned on, so at the top of your script, you can say:
ini_set('display_errors', true);
error_reporting(-1);
And that will allow you to see the error.
However, it isn't the best way. Error logging directly to the screen not onl;y distorts your page, but can ruin header() calls, as the HTTP body has already started outputting and thus no more HTTP headers can come out.
For the best error logging experience, 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.

I don't know this library, but var_dump shows that unprotected data from PHP 5.6.0.
Maybe the problem comes from there?
Look at the __debugInfo() method
And give us the exit.

Related

Wordpress - The Jetpack server could not communicate with your site’s XML-RPC URL

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.

How to change a setting to true in a PHP file?

I have an Apache2 web server with PHP 5.5 installed.
My default PHP settings is display_error = 0 (I don't need globally displayed errors) but I need it on in specific PHP files.
I tried with:
error_reporting(E_ALL);
ini_set("display_errors", 1);
and it's not working.
Can someone tell me how can I make it show errors in specific PHP files?
i am try to force some error writing some no syntax logic and not showing error...
To show parse errors in PHP you have to put this on your php.ini
display_errors = on
My advice is to avoid displaying errors on production servers but log them all. So you can later inspect and fix bugs from yoursite-error.log file.
You should be concerned if your applications has warnings, errors etc. IMHO it is a bad idea to focus your attention only on few files instead of them all.
Although display_errors may be set at runtime (with ini_set()), it won't have any effect if the script has fatal errors. This is because the desired runtime action does not get executed.

PHP Error message in Firefox not Chrome

One of our websites earlier today started outputting a few PHP warnings that were only visible through Firefox but weirdly the errors wouldn't show in Chrome or Safari.
I had a look at the request/response headers and noticed in the response header for Firefox the entry
X-pad: avoid browser bug
Could this be the reason for the discrepancy in between the two browsers? From what I could find, X-pad was a work around for a bug that existed in an ancient browser.
Below is a screenshot of the errors from Firefox.
Error Message
Edit.
Found out the cause of the error and also why chrome wasn't showing the warnings. A number of pages on our site had been injected with some code, as documented here. The code was ignoring safari and chrome , but not Firefox. Hence the discrepancy.
As for the fix, simply remove any instances of the code. Affected, were instances of index.php/template.php/page.php files.
Uninitialized string you get because your variable is not setted in an array. Make sure that is setted.
if (isset($somevar['var']))
{
// etc..
}
Your session_start() code is NOT on your TOP in a PHP file. A session_start() should be called before all scripts executed.
To turn off showing errors manually via PHP put on top:
ini_set("display_errors", 0);
Put all your errors to error.log file instead of showing errors on PHP production environment.
X-Pad is header appender to the response from apache. So this isn't way what errors occured. X-Pad doesn't relation with your errors.

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 website does not work, and nothing logged in the error log

I have a problem with PHP. There is an error that I have never encountered before. The home.php, which is the main page of my site, cannot be viewed. And there is nothing in error log. After there is an inclusion of a php page (a class that is a part of my API). Till that line the holl HTML (javascript and css inclusions) are echoed from php and successfully rendered in browser, but after the php kind of stops suddenly. When I delete that line(php page inclusion line), website works, but before, this inclusion didn't make any problem for me. I removed the code parts which after them I encountered this problem, but nothing works.
I am using Apache2, PHP5 with Ubuntu 11.10.
Any help will be appreciated, thanks in advance.
My first hints would be to check the following:
In your script set ini_set('display_errors', '1'); and error_reporting(E_ALL); to display all errors.
Turn on the php error log and check it for errors.
run php -l home.php on the command line to check your php file for syntax errors.
Check Apache's error log, sometimes error messages go there.
If nothing helps use a debbugger like XDebug to see where the script terminates, or alternative insert statements like die("here"); and move them around in your code, to see which parts of your scripts are passed.
Greetings and good luck.

Categories