Jump to content

[SOLVED] Quotes


waiwai933

Recommended Posts

The main differences:

 

In "", variables are parsed, and in '' they're not.

 

 

`` is not technically a quoting delimiter.  It is used in PHP to execute system commands in most contexts.  Example:

 

echo `dir`;

 

Would list the files in the current directory if permissions allowed that.

 

 

`` is also used to wrap object names in MySQL.  Example:

 

SELECT `col1` FROM `some_table`;

Link to comment
https://forums.phpfreaks.com/topic/136793-solved-quotes/#findComment-714440
Share on other sites

I see. That makes much sense. So why do we sometimes use '{$variable}' and other times we use `$variable` in MySQL?

 

 

Anything wrapped in `` in MySQL is treated as an object.  Object might not actually be the right term there.  What I mean is the name of something.  A table, database, column, stored procedure, whatever.

 

The single quotes are usually used in double quotes:

 

$query = "SELECT * FROM table1 WHERE column1 = '{$var}';";

 

Then, since the $var is in double quotes, it would be parsed.

Link to comment
https://forums.phpfreaks.com/topic/136793-solved-quotes/#findComment-714447
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.