I can't get the following code to work correctly:

echo "<h1>" . $ip . "</h1>";

It outputs this:

" . $ip . ""; ?>

But when I create a php file and throw the php into it I get the result I want:

echo "<h1>" . $ip . "</h1>";


(My IP Address)

Hey i checked your code..It's working fine ...it's showing the my IP ....What's the problem??

You are probably saving the the top code as a .html file, but you need to save it as a .php file if you are going to include php in it. The html will all still work perfectly fine, but you'll be able to execute php inside of the html now.

Member Avatar

As ct says, .html or .htm files won't usually run php. You can set them to do so with in .htaccess file:

AddType application/x-httpd-php .html

Why do you need to save it as *.html?? I'd just use the *.php extension.