Question

I have been searching on forums and google for hours with no definitive answer other than "Your host may not support PHP". I have dumbed down my PHP page to simply display some text for testing purposes but I am still only getting a blank webpage. I have tried opening it locally into a browser and also through the web server, same result for both. Anyone have an idea as to why this simple PHP wont even show up on the webpage?

<?php
echo "Show some text";
?>

also tried:

<html>
<?php
echo "Show some text";
?>
</html>

No correct solution

OTHER TIPS

What is the filename of your file? Is the file extension a .html file, or a .php file? If it's .html, rename it to .php and test with your first test again.;

To check and see if php is supported on your server, create another file titled: phpinfo.php and insert the following code in it:

<?php
    phpinfo();
?>

and save it, and then go to it on your server. You should see the PHP configuration output on that page. If it doesn't work, then you do not have PHP correctly installed on your server.

Your file must be ending in .phtml or .php to make PHP work on a HTML page.

index.php

<?php
echo "Hello World!";
?>

Or you can trick your server, Apache and Nginx support this as does IIS. Basically you can have "index.x" or "index.px" - your own custom extension, it is not advisable for obvious reasons. In Apache (your public_html folder) enable this in your .htaccess file:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .ac1d
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .phtml 
AddType application/x-httpd-php .x 
# your custom extension above.

To view the source of everything (no processing):

Most server are setup with a source-viewing format already by changing the file name to use the .phps extension. If not, you'd have to create a .htaccess file and temporarily add this line to it:

AddType text/plain .php
AddType text/plain .html

That should force the files to be displayed as plain text whenever they're accessed. Just remember to remove it later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top