|
Posted by Rami Elomaa on 07/07/07 08:55
joboils@hotmail.com kirjoitti:
> I've inherited a huge, rambling site with numerous lines containing
> $_SERVER["HTTP_POST"]
> php.net says it should be single inverted commas, not double, yet
> everything seems to work. As it would be a considerable amount of
> work to change everything, can I safely leave things as they are?
> TIA.
I'm sure you've misinterpreted the manual. The syntax above, with double
quotes is prefectly fine. All it does is that it delimits a string
literal, for this puropuse double quotes and single quotes are just
fine. The reason single quotes is _preferred_ (but not required) is that
in this case it's slightly faster. You see, double quoted strings may
containt php variables that are replaced with the string values of the
variables. Single quoted strings do not have this quality, and that is
the reason they work a little bit faster than double quoted strings.
But like the wise man said: if it works, don't fix it. You can leave it
just like that and be cool with it. I'm sure the possible improvement in
performance that you'd gain from changing each double quote to single
quote is nominal, you'll do nothing but waste your time.
Finally a little example to demonstrate the difference.
<?php
$cat = "Garfield";
echo "That $cat is so funny!"; // Double quotes
// This will print: That Garfield is so funny!
// $cat is changed into its value.
echo 'That $cat is so funny!'; // Single Quotes
// This will print: That $cat is so funny!
// No changes are made, printed literally as it's written.
--
Rami.Elomaa@gmail.com
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
[Back to original message]
|