Embedding PHP in HTML

I am trying to embed PHP in an HTML document but it is only displaying a blank page. Any idea what I am doing wrong?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 //Gets the IP address
 $ip = getenv("REMOTE_ADDR") ; 
 Echo $ip; 

Would it just be easier to rename your page to .php?

I figured it out.

AddHandler application/x-httpd-php5 .html .htm

in the .htaccess will work.

Though I am told this is inadvisable. Any idea why?

Same here :lol:

I just tested it too, and it does work.

Who knew you could use a capital e there? Not me…

The script works for me as it displays the ip address, are you using the page on your pc or on a webhost server?

“echo” has a lowercase e.

echo $ip;

I am using it on a Hostgator account.



Function and statement names aren’t case sensitive in PHP. I don’t think class names or constants are either, but I’m too lazy to look that up right now.

AddHandler application/x-httpd-php5 .html .htm

Probably because now it makes HTML files executable. Just one more conduit you have to watch out for.

Nothing really wrong with it, in an of it self.