when is necessary to use the dot?

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!

Moderator: General Moderators

Post Reply
jiehuang001
Forum Commoner
Posts: 39
Joined: Mon May 12, 2003 12:53 pm

when is necessary to use the dot?

Post 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;
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post 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;
?>
Post Reply