Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpinfo() outputs nothing

Tags:

php

apache

I've tried phpinfo() but it output nothing. It is interesting that php-r "phpinfo();" works correctly while using phpinfo() in web outputs nothing. Again, nothing is written to error.log too. php.ini is empty.

I don't know what to do now.

Edit:

Thanks to lanzz, I got that phpinfo() requires no output before it.

like image 990
Uhehesh Avatar asked May 28 '12 21:05

Uhehesh


3 Answers

I had a similar issue. I am running Apache2 on my Ubuntu machine for local testing of projects before deployment. I created a phpinfo(); page, and noticed it was blank. Upon inspecting in my browser, the php function would be commented out.

Your browser has nothing to do with php.

In order for PHP scripts to execute, you have to save the file as a .php file, which I'm sure you did.

PHP tags alone aren't valid in HTML documents, so you need to create an actual HTML document, and save it as .php. Then, include a basic HTML document like so:

<?php
   phpinfo();
?>

<html>
  <head>
    <title>Php Info</title>
  </head>
    <body>
    </body>
</html>

Then you would do: localhost/phpinfo.php or whatever you're working on. In my case it was an actual domain name that was mapped to my localhost, so 'myProjectName'.com/phpinfo.php

This is just from my experience and it worked 100%.

like image 153
DevOpsSauce Avatar answered Sep 22 '22 12:09

DevOpsSauce


First, Check the content of your "access.log" ; if you don't see the call to the phpinfo file, you certainly have a problem on your web server.

Otherwise, try to get a simple php file :

<?php echo "Hello, world.";

Or HTML file :

<h1>Hello, world !</h1>

Then you can determine where is the problem.

Perhaps the PHP module for the web server isn't loaded.

like image 34
Akarun Avatar answered Sep 20 '22 12:09

Akarun


Just wanted to add, that I was using short tags '<?'

<? phpinfo();

which was failing, becuase I was using short tags when they were disabled so it should have been

<?php phpinfo();
like image 38
Shaun Forsyth Avatar answered Sep 24 '22 12:09

Shaun Forsyth