Results 1 to 4 of 4
I am not familiar with PHP, just the basic... very basics! Could someone tell me what this code would do and if the syntax is all correct.
Thanks
Code:
<?php
...
- 08-01-2007 #1
Whta does this PHP code do... and is it correct?
I am not familiar with PHP, just the basic... very basics! Could someone tell me what this code would do and if the syntax is all correct.
Thanks
Code:<?php $ip = getenv("HTTP_HOST"); if ($ip == "www.website.com" or $ip == "website.com") { Header("Location: website/index.html"); exit; } ?> <?php if ($_GET['server'] == true) { phpinfo(); } ?> //Not sure why this is here. <a href='http://anotherWebsite.com'>Click Here!</a>
- 08-02-2007 #2
The first block redirects requests for www.website.com or website.com to the index.html file (in case the Web server doesn't do it automatically, which it should if it's configured right).
The second block looks to see if the URL includes something like "?server=true" tacked onto the end, and if so, shows a page of information about the installed version of PHP.
The last line would be shown if none of the above is true (i.e., the user got there by some means other than navigating to www.website.com or website.com, and there's no "?server=true" in the URL).
As far as I can tell, the syntax is correct. You might want a second opinion, since I'm just going off memory and limited understanding (can't test it from where I am).Stand up and be counted as a Linux user!
- 08-02-2007 #3
I wasn't sure exactly sure if that's what it would do. You answered my question! Thanks!
- 08-02-2007 #4
That's basically right, though it should be noted that because the second if doesn't have an exit, if you go to something like www. foo .com?server=true, the link would still show.
Also note that because you're using '==' and not '===', any true value will work in that second if. Therefore, ?server=a would work, etc. '===' would not work in this case, because (as far as I know), you cannot send in a PHP true value through GET.DISTRO=Arch
Registered Linux User #388732


Reply With Quote