Logo F2FInterview

PHP Interview Questions

Q   |   QA

There are two special characters you need to escape in a single-quote string: the single quote (') and the back slash (). Here is a PHP script example of single-quoted strings:
<?php
echo 'Hello world!';
echo 'It's Friday!';
echo ' represents an operator.';
?>
This script will print:
Hello world!It's Friday! represents an operator.

You can not specify the "new line" character in a single-quoted string. If you don't believe, try this script:
<?php
echo ' will not work in single quoted strings.';
?>
This script will print:
will not work in single quoted strings.

There are 2 escape sequences you can use in single-quoted strings:

  • - Represents the back slash character.
  • ' - Represents the single quote character.

There are two special characters you need to escape in a double-quote string: the double quote (") and the back slash (). Here is a PHP script example of double-quoted strings:

<?php
echo "Hello world!";
echo "Tom said: "Who's there?"";
echo " represents an operator.";
?>

This script will print:

Hello world!Tom said: "Who's there?" represents an operator.

There are 12 escape sequences you can use in double-quoted strings:

  • - Represents the back slash character.
  • " - Represents the double quote character.
  • $ - Represents the dollar sign.
  • - Represents the new line character (ASCII code 10).
  • - Represents the carriage return character (ASCII code 13).
  • - Represents the tab character (ASCII code 9).
  • { - Represents the open brace character.
  • } - Represents the close brace character.
  • [ - Represents the open bracket character.
  • ] - Represents the close bracket character.
  • nn - Represents a character as an octal value.
  • xnn - Represents a character as a hex value.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: