Quotes vs. Single Quote
| From: | Rick Dwyer | Date: | Fri, 06 Aug 2010 02:10:26 +0000 |
| Subject: | Quotes vs. Single Quote | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-307327@lists.php.net to get a copy of this message | ||
Hi List.
I've mentioned before that I am both just beginning to learn PHP AND I have inherited a number
of pages that I'm trying to clean up the w3c validation on.
Something that confuses me is how the code on the page is written where in one instance, it follows
this:
echo "<table border='1'><tr>....
And elsewhere on the page it follows:
echo '<table border="1"><tr>....
In what I've read and from many of the suggestions from this board, the latter seems to be the
better way to code, generally speaking.
So given that the page has javascript in it, perhaps the reason for the previous developer switching
between the two was for ease of incorporating JS?.... Don't really know... but what I would
like to know is it considered poor coding switch between the two on a single page or is it perfectly
acceptable?
2nd question, in the 3 lines below:
$_SESSION['newpage'] = $newpage;
$checkstat = "select field from table where fieldid = $field_id";
$result1 = @mysql_query($checkstat,$connection) or die("Couldn't execute query");
If I were to recode in the latter style, should they not look like this:
$_SESSION['newpage'] = $newpage;
$checkstat = 'select field from table where fieldid =
"'.$field_id.'"';
$result1 = @mysql_query($checkstat,$connection) or die('Couldn\'t execute query');
The focus being here:
"'.$field_id.'"';
('Couldn\'t execute query')
Is this correct?
Thanks for the help.
--Rick