Databases Reference
In-Depth Information
You can also include quotes using the backslash character as an escape code:
$string = "This string includes a double \" quote";
$string = 'This string includes a single \' quote";
To include a backslash character, escape it with a backslash:
$string = "Here's a \\ blackslash character";
Unlike most other languages, you can incorporate carriage returns and line feeds di-
rectly into strings:
$string = "Here's a string spread over
two lines";
You can also include carriage return, line feed, and tab characters using the \n , \r , and
\t shortcuts, respectively:
$string = "This string is spread over\n two lines. And it has a \t tab in it.";
Adding newlines and tabs in content sent to the browser makes the HTML source more
readable. However, such whitespace has no significance in HTML unless you enclose
the text in <pre> tags to mark it as preformatted content. Adding such whitespace
characters often comes in handy when developing and debugging an application, but
you can also safely omit them in production code.
Arrays
Arrays can be accessed by their numeric or associative index. Numeric indexes are
numbered from zero. Consider two sample arrays:
// This is an associative array
$x = array("one" => 1,
"two" => 2,
"three" => 3);
// The value 1 from the array $x is placed into the variable $y
$y = $x["one"];
// This is a numerically indexed array
$a = array(10, 20, 30);
// This places the value 20 from the array $a in the variable $b
// (since arrays begin with an index of 0)
$b = $a[1];
You can create and manipulate arrays using the indexes. For example, in addition to
using the array( ) syntax:
$x = array(10, 20, 30);
you can access the elements directly and get the same result by writing:
 
Search WWH ::




Custom Search