Andwise
September 13, 2010, 8:52pm
1
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">
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo $ip;
?>
</body>
</html>
Would it just be easier to rename your page to .php
?
Andwise
September 14, 2010, 3:29am
3
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?
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;
Andwise
September 14, 2010, 1:05am
8
I am using it on a Hostgator account.
xennnova.com/ip
Thanks,
Andy
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.
Cheers,
Alex