I tried searching for an answer, but I'm not sure how to word the question so that it fits into a search box.

I found out a month or so ago that if you are accessing variable data like $_POST or after a mysql_fetch you can use $row but it also seems to work just fine when you don't use the quotes, i.e. $_POST[user] and $row[id].

So I've built two entire websites without using the quotes, but recently I had to do some work on one of the sites and when I turned on error checking every instance where I didn't use the quotes generated a notice. I've also noted that this site is "really" slow and that got me to wondering. . . (see? how do you fit that into a textbox?)

Does anyone know if not using the quotes around the field names slows PHP down? Are there any other problems created by not using the quotes?

Ardav, I'm looking at you here. :)


Recommended Answers

All 2 Replies


It is correct PHP to use quotes, although it works without. This can lead to errors, should you have a const defined with that name for example.

$row = array ('user' => 'foo', 'myusername' => 'bar');
define('user', 'myusername');
echo $row[user];
echo $row['user'];

So, my guess it it will be slower without. I think it will try to find a matching const first, and if there isn't any revert to the string version.

Okay. I think I won't worry about going back and fixing the other site. Thanks, Pritaeas! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.