Page 1 of 1

when is necessary to use the dot?

Posted: Tue May 27, 2003 8:29 am
by jiehuang001
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;

Posted: Tue May 27, 2003 8:57 am
by AVATAr
the dot when using with string is "concatenation".

so, all these are valid:

Code: Select all

<?php
$id = $_POST['id'];  //Number

$sql_1 = "select * from usertable where id = $id"; 
$sql _2 = "select * from usertable where id = ".$id;

$sql _3 = 'select * from usertable where id = '.$id;
?>