+ 2

Sometimes there are single quotation marks and sometimes double quotation marks for text assigned to a variable. Is there a difference between them?

23rd Nov 2015, 4:48 PM
Sophie
Sophie - avatar
8 Antworten
+ 2
If you use double quotes PHP parses the string looking for variables and put in the string the value of found variables. It's best to suround your variables with curly brackets, if used inside a string. I don't recommend the use of variables inside a double quoted string due to performances aspects, especially if string is long. Better use the concatenation operator, like: <?php echo 'This is a string concatenated with a ' . $variable . '!'; ?>
23rd Jan 2016, 1:18 PM
Elena Alexie
Elena Alexie - avatar
+ 1
Hello Sophie, you can use it like this: 1.$fullname="Alex $lastname" or 2.$fullname='Alex'.$lastname all forms are correct but for big projects i recomand you to use form "2".
20th Feb 2016, 9:34 PM
Filip Lucian
Filip Lucian - avatar
+ 1
Single quotes show the original value that you give it (except one thing that I'll say); but double quotes convert two things: 1. Variables => Their values 2. Escape characters => Characters Note: Single quotations just convert some escape characters. See this: http://www.sololearn.com/app/php/playground/wktcjWiMAyq8/
25th Jul 2016, 10:47 AM
$machitgarha
$machitgarha - avatar
0
yes if u put single and put a variable name in it it would retrieve the value and use the value bug if u put double is will use just the characters and will not think of it as variables
16th Dec 2015, 9:23 AM
mahmoodreza roodafshani
mahmoodreza roodafshani - avatar
0
Not really. But double quotation marks are often used when you are embedding a variable in the output statement. eg: echo "Hello {$variable_here}";
19th Dec 2015, 5:33 PM
deepak
0
when you use double quotation marks you can include variables, and wehen you use single quotation you can echo literal that sequences
29th Jan 2016, 1:33 PM
Mihai Stuparu
Mihai Stuparu - avatar
0
Short answer: Codes get evaluated in double quotes but not in single ones. example: <$php $t=test; echo 'this is a $t' //output: this is a $t echo "this is a $t //output: this is a test ?> _____________________ expansive answer: read following page: http://www.lightrains.com/blog/difference-single-quote-double-quote-string-php#gsc.tab=0
12th Mar 2016, 3:37 AM
Javad Noori
Javad Noori - avatar
20th Jan 2016, 8:01 PM
Kyizin
Kyizin - avatar