77Chapter 5Syntax and VariablesOn the other hand, code (Simple web server)
77Chapter 5Syntax and VariablesOn the other hand, code like this: $authorization = NULL; // code that might or might not set $authorizationif (test_authorization($authorization)) { // code that grants a privilege of some sort} does not cause an unbound-variable warning, assuming that you have written test_ authorization()to handle arguments that might be NULL. It also makes clear to a reader of the code that you intend for the variable to lack a value unless there s a case where it isassigned. StringsStringsare character sequences, as in the following: $string_1 = This is a string in double quotes. ; $string_2 = This is a somewhat longer, singly quoted string ; $string_39 = This string has thirty-nine characters. ; $string_0 = ; // a string with zero charactersStrings can be enclosed in either single or double quotation marks, with different behavior atread time. Singly quoted strings are treated almost literally, whereas doubly quoted stringsreplace variables with their values as well as specially interpreting certain charactersequences. Singly quoted stringsExcept for a couple of specially interpreted character sequences, singly quoted strings readin and store their characters literally. The following code: $literally = My $variable will not print!\n ; print($literally); produces the browser output: My $variable will not print!nSingly quoted strings also respect the general rule that quotes of a different type will notbreak a quoted string. This is legal: $singly_quoted = This quote mark: is no big deal ; To embed a single quote (such as an apostrophe) in a singly quoted string, escape it with abackslash, as in the following: $singly_quoted = This quote mark s no big deal either ; Although in most contexts backslashes are interpreted literally in singly quoted strings, youmay also use two backslashes (\) as an escape sequence for a single (nonescaping) back- slash. This is useful when you want a backslash as the final character in a string, as in: $win_path = C:\InetPub\PHP\ ; print( A Windows-style pathname: $win_path
); which displays asA Windows-style pathname: C:InetPubPHP
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.