Re: Style questions: variable in echo, preparing sql queries

From: Date: Wed, 22 Nov 2000 21:03:36 +0000
Subject: Re: Style questions: variable in echo, preparing sql queries
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26716@lists.php.net to get a copy of this message
Hello Chris, (CL == "Chris Lott") chris@intranet.dist-ed.uaf.edu writes: CL> Two questions about style: CL> CL> 1) echo "PartID is $PartID"; CL> seems to work fine. Is there a reason that I see others use: CL> echo "PartID is " . $PartID; Well if they're trying to be `proper' they might as well use single quotes around 'Part ID is' because there is nothing to be interpolated. Personally, I just stick to echo "PartID is $PartID"; CL> 2) When querying a db, I see users who do something like: CL> $sql = "select foo from bar"; CL> $results = mysql_query("$sql") No need for the quotes. $results = mysql_query($sql) CL> Is there a reason not to just put the SQL code directly in the function: CL> $results=mysql_query("select foo from bar") ? No. Separating the SQL from the execution is AFAIK just for readability. -Brian -- Enter any 11 digit prime number to continue.

« previous php.general (#26716) next »