+ 2
Sometimes there are single quotation marks and sometimes double quotation marks for text assigned to a variable. Is there a difference between them?
8 Respuestas
+ 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 . '!'; ?>
+ 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".
+ 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/
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
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}";
0
when you use double quotation marks you can include variables, and wehen you use single quotation you can echo literal that sequences
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
- 2
Read the PHP Documentation.
http://php.net/manual/en/language.types.string.php