I am very fresh to PHP..., if you consider the following statement.. echo "Your IP Address is " . $_SERVER['REMOTE_ADDR']; it prints my ip but.., if i change to ---> echo "Your IP Address is . $_SERVER['REMOTE_ADDR']"; then to ----> echo "Your IP Address is " $_SERVER['REMOTE_ADDR']; it showing errors..., whats wrong.. > i need to know what is the importance of dot ( . ) before $_SERVER['REMOTE_ADDR']; > why statement 1 ( echo "Your IP Address is . $_SERVER['REMOTE_ADDR']"; ) is wrong Please give good explanation as i am very new to PHP.., thanks friends..!
dot (.) is a string operator to concatenate you can also do comma (,) in echo macro like ---> echo "Your IP Address is ", $_SERVER['REMOTE_ADDR'];
Because PHP manual shows you that an array should be wrapped into curly brackets ( { } ) ? echo "IP: {$_SERVER['REMOTE_ADDR']}"; PHP:
We are talking about arrays here, not just variables. Can and should doesn't mean the same in the context of what he asked / I replied.
$_SERVER['REMOTE_ADDR'], was this array or varialbe...., why, <?php $a = 10; echo " this is $a " ?> prints ----> this is 10 But why not <?php echo " $_SERVER['REMOTE_ADDR']"; ?>
Ya its working...!, thanks but friends why this was not working if we put single quotes in it like echo "Your IP Address is $_SERVER['REMOTE_ADDR']";
1. Dot joins the Output of PHP Variable with a Text precedes that See my signature 2. The Text should be separated from a Variable Also If you're going to use $_SERVER[REMOTE_ADDR] for detecting IP its not advised because it returns Proxy's IP when your using Proxy So indeed i have a Algorithm for detecting a Real IP If you need just Ping me (It hides in my HP NoteBook somewhere else so only)
Oops..! upto now i believe $_SERVER[REMOTE_ADDR] will gives the original ip......, but i need to get real ip..., if you have the algorithm please PM i really required this...!
Oops! I hope it went into MacBook So i have no other way but i built using the algorithm written here http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html Sorry!
Learning PHP is ease! If you run into issues Google that and post here too You can get your stuffs enriched easily Minimum i will Google 100+ times a Day