PHP: Strings

Every string can be stored in a manner similar to explained in Variables section.

Example: $string_var = “Bob”;

Double quotes permit you to use special charaters as follows:


<?php

// All the string described belows are VALID.

$string = "Hello world!";

$html_string = "<a href='my-webpage.html'> my home </a>";

$html_string_backslash= "<a href=\"my-webpage.html\"> my home </a>";

$special_char_string_newline = "hi. This is Bobby \n";

$special_char_string_tab = "hi. This is Bobby \t";

?>

Note that all the string defined above are valid. Also, note that we often need to enclose double quotes in HTML tags and then we can simply use single quote (‘) to handle the string as done in the variable $html_string above or use backslash(\) followed by double quotes (“) to handle it.

All the special characters like \n, \t can also be included in string defined within double quotes (“).

css.php