LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP pages are displayed as blank pages (https://www.linuxquestions.org/questions/linux-software-2/php-pages-are-displayed-as-blank-pages-625105/)

Hirszu 03-02-2008 06:29 AM

PHP pages are displayed as blank pages
 
I recently compiled Apache 2.2.8 and PHP 5.2.5 from source and did everything as in the official PHP documentation. The weird thing is that I've got blank pages on almost every PHP page. One script works and I don't know how it's possible. I used to run nginx before, but I removed it. The Ubuntu packages also don't work.

My httpd.conf is the default one with PHP enabled. My php.ini is the default php.ini-recommended. How can I fix this weird behavior?

bathory 03-02-2008 08:08 AM

Use:
Code:

short_open_tag = On
in php.ini to see if it works.

Hirszu 03-02-2008 09:38 AM

I'm using my own scripts and I'm aware of the short_open_tag variable, so I use the <?php open tag. Anyway, I tested it and it doesn't work.

If I create a phpinfo script, it works. If I run a more complex script like
Code:

<?php
// here some requires
// and a class definition
?>
<!-- here comes the html -->
<?php
// an echo
?>

it spawns a blank page. If PHP weren't working properly, I'd see only the HTML with the PHP code in the source and not a blank page.

Wim Sturkenboom 03-02-2008 09:52 AM

check the apache log file for hints; I don't have access at the moment to my slackware server, but somewhere in /var/log/

//edit:
you start with PHP open tag; if something goes wrong in that first part (before you get to the html part), apache might/will abort resulting in blank page

Hirszu 03-02-2008 12:20 PM

Ok, it seemed to be a stupid question. I had display_errors turned off in my php.ini and my scripts are spawning errors so I've got blank pages as result. Thanks anyway!

EOT

jiml8 03-02-2008 12:31 PM

that'll do it every time!

If you have php installed for use from the command line, you can also try to run your scripts by the invocation php myscript.php.

If you get html text output, you are good to go. Otherwise, you will get descriptive error messages, regardless of what the PHP plugin to apache is configured to do.

Also, if you have php available at the command line, then starting a script with shebang php lets you run scripts written in php exactly the same way you run perl scripts or bash scripts.

Specifically, on my system, if the first line is:

#!/usr/bin/php

then I can execute php scripts like any other command.

Wim Sturkenboom 03-03-2008 12:09 AM

Quote:

Originally Posted by Hirszu (Post 3075815)
Ok, it seemed to be a stupid question. I had display_errors turned off in my php.ini and my scripts are spawning errors so I've got blank pages as result. Thanks anyway!

EOT

My opinion:
If this is a production server, it should be off for security reasons. Under other circumstances (e.g. development), it's up to you.


All times are GMT -5. The time now is 10:08 PM.