PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, I've just begun working with PHP, and I've run into a problem displaying superglobal variables. Here is the code I'm using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>superglobals</title>
<meta http-equiv="Content-Type"
content="text/html"; charset=utf-8" />
</head>
<body>
<?php
print "Your IP Address is: $_SERVER['REMOTE_ADDR'] <br />";
print "Your browser is: $_SERVER['HTTP_USER_AGENT']";
?>
</body>
</html>
When I open this file in my browser (Firefox), nothing at all is displayed, including the non-variable strings. Nothing at all appears in the browser. Yet if I run the phpinfo() function, all of the superglobal (among many others) variables display perfectly. I have tried using the 'echo' function instead - still I get the same result. I'm running Apache 2.2.4 and PHP 5.2.0, and I've tried this in both Firefox and IE. Any ideas, suggestions?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks, this helped me get the variables to output correctly. Not sure why the book I'm working through gave the code the way it did, but I'm straightened out now. Thanks again.