waiwai933 Posted December 13, 2008 Share Posted December 13, 2008 Hi everyone. What are the differences between the three types of quotes? (ie. ', ", `) Is there perhaps an online manual for these sort of simple questions? Link to comment https://forums.phpfreaks.com/topic/136793-solved-quotes/ Share on other sites More sharing options...
corbin Posted December 13, 2008 Share Posted December 13, 2008 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 More sharing options...
waiwai933 Posted December 13, 2008 Author Share Posted December 13, 2008 I see. That makes much sense. So why do we sometimes use '{$variable}' and other times we use `$variable` in MySQL? Link to comment https://forums.phpfreaks.com/topic/136793-solved-quotes/#findComment-714442 Share on other sites More sharing options...
corbin Posted December 13, 2008 Share Posted December 13, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.