Apparently both $sql_1 and $sql_2 in the following are valid. Can someone tell me when is the right time to use the "."? It seems to me that the dot can be functioned as both "||" and "+" in java.
$id = POST[id]; $sql_1 = "select from usertable where id =$id¡±; $sql 2 = "select from usertable where id =".$id;
In PHP, the dot operator is the string concatenation operator.
You use a dot in cases like this:
print "Welcome" .$user.,"Have a good day";
:p
yeah except sleepingdanny you messed it up a little
you have
it should be
echo "Welcome" . $user .", Have a good day";
comma inside the quotes, not outside, and i prefer echo
My mistake... :rolleyes:
I make it a rule to always use the .'s. I never have variables inside of quotes, I find it less confusing that way. You COULD do this:
echo "Hello, $username, welcome to my site!";
However, I prefer this:
echo "Hello, ".$username.", welcome to my site!";
i always stay away from putting variables inside of quotes also, except when i run my queries for some reason