I have PHP installed on my CENTOS server. However, when running a phpinfo() inside my script to test it, I receive the HTML, not the interpreted information. I can see the folders for PHP. I can even see the php.ini in the etc folder. But php itself does not seem to be working. I mean my test.php file looks like this:
<?php
phpinfo();
?>
And the response looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
...
and so on.
What seems to be the problem and how do I solve it? If I copy the HTML returned, paste it into an HTML file, and run it from there, I can see the formatted result, but not by running the test.php. I assume php is not loaded somehow... even if in the interpreted HTML I can see the :
**Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
additional .ini files parsed /etc/php.d/dbase.ini, /etc/php.d/json.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.bzip2, compress.zlib, https, ftps**
and so on...
On this system, there are 3 websites hosted. Does that have anything to do with this problem?
Just had the same issue and found that a client had disabled this function from their php.ini
More info: Enabling and disabling phpinfo() for security reasons
It may not work for you if you use localhost/info.php. You may be able to found the clue from the error. Find the port number in the error message. To me it was 80. I changed address as http://localhost:80/info.php, then it worked to me.
try to create a php.ini file in root and write the following command in and save it.
using this code will enable phpinfo() function for you if it is disabled by global php configuration.
You need to update your Apache Configuration to make sure it's outputting php as the type text/HTML, the below code should work but some configs are different.
This happened to me as well. The fix was wrapping it in html tags. Then I saved the file as /var/www/html/info.php and ran http://localhost/info.php in the browser. That's it.
Be sure that the tag "php" is stick in the code Like this
?php phpinfo(); ?>
Not like this
? php phpinfo(); ?>
OR the server will Treat it as a (normal word) so server will not understand the language you are Writing to Deal with it so it will be blank .
I Know it's a silly Error ...but it happened ^_^