PHP Quotes

PHP-Quotes
php, core php, php with gaurav


Quotes indicate text (or information that is treated as text)
    Referred to as text string

Single quotes:
  echo $a; // results in the value of  $a being printed
  echo '$a'; // results in the word $a bring printed

To specify a literal single quote, put a backslash in front of it
  echo 'Who said: "I \'ll be back"?';
  // Who said: " I'll be back"?

  • Strings are surrounded by either single or double quotes. If you use double quotes, you can put a variable in a string and the results of echoing or printing that strings will include the value of the variable.
  • To specify a literal single quote, you will need to escape it with a backslash (\), like in many other languages. If a backslash needs to occur before a single quote or at the end of the string , you need to double it.
  • The results of echoing or printing that string will include the value of the variable:
echo "$a"; // results in the value of $a bring printed.
$link = "<a href='http://mycompany.com'>Example</a>";
  • This called "Variable interpolation".

1 Comments

Previous Post Next Post