Code: Select all
$_POST["tags"]Code: Select all
$_POST['tags']which is better or which is preferred?
Moderator: General Moderators
Code: Select all
$_POST["tags"]Code: Select all
$_POST['tags']Ok ,scottayy wrote:In the way the code is executed, it doesn't make a difference.
But, how it differs:
PHP will try to interpret any variables and other characters when the code is between double quotes. So, use single quotes when you don't have any variables or other characters like new lines in your string. Using single quotes lets PHP know that it doesn't need to interpret anything, and is probably a bit faster.
Which is preferred? That's your own call...
Code: Select all
$_POST['name']No, 'name' isn't variable, it's a static string. This would be variable:kkonline wrote:Ok ,scottayy wrote:In the way the code is executed, it doesn't make a difference.
But, how it differs:
PHP will try to interpret any variables and other characters when the code is between double quotes. So, use single quotes when you don't have any variables or other characters like new lines in your string. Using single quotes lets PHP know that it doesn't need to interpret anything, and is probably a bit faster.
Which is preferred? That's your own call...
now if i am usingthen as name is a variable so i SHOULD use DOUBLE QUOTES ???Code: Select all
$_POST['name']
Code: Select all
$name = "name";
echo $_POST[$name];
//or even
echo $_POST["foo_$name_bar"]; //foo_name_bar