Magic Quotes: Strings are constructed within double or single quote marks; to avoid confusion, any quotes inside the string should contrast with the enclosing (outer) marks. Setting php.ini with magic_quotes_gpc set to "on" (the default) and magic_quotes_runtime to "on" ("off" is default), you can automatically strip or add slashes to escape any single or double quotation marks, backslashes, and NULL characters for GET, POST, and cookie operations. To tell whether this is set, use get_magic_quotes_gpc(), which returns 1 or 0, depending on the current value of magic_quotes_gpc; if "on" (1), you'll want to strip out escapes using stripslashes(). You can turn on magic quoting in a script (regardless of php.ini settings) using set_magic_quotes_runtime().
Evaluating Strings: Eval() evaluates a string as PHP code, and executes it. This is useful when the code is stored in a database or created on the fly in a loop. Code stored in databases can include templates or pieces of html, php, or plain text, which can be formatted before being output by eval().
Terminating Execution: Exit; and die() are two means to execute a script (in, say, an error handling scheme). You can also pass a string (e.g., an error message) to die(), or a function (e.g., to print a message, close files, go away nicely). This is often coupled with a statement that might fail, such as the execution of a query string, as
mysql_query($strquery) or die(last_will_and_testament());.
Serialization: Study p. 498 to see how serialize() and unserialize() pack and unpack bytestreams, letting you store them or pass them (similar to the first approach that I used to pack isbn numbers in worked-code example for assignment 6. You'd be better off, however, using session variables.
Information about PHP Configuration: Get_loaded_extensions() and get_extension_funcs() return arrays of all functions sets and functions within sets that are currently availabe (i.e., made available throught php.ini).
Getlastmod() returns a unix timestamp for when a script was last modified. Use it as echo date('g:i a, j M Y', getlastmod());
If php.ini has enable_dl set, you can dynamically load extensions (dynamic link libraries, dll, in windows, as dl('php_gd1.dll');, which would load the gd2 image generation. See p. 500 for more on php.ini settings.
Access and change directives in the php.ini file for a single session using ini_get() and ini_set(); listing 23.2 shows how to change a timeout setting this way. (more)
Highlighting and displaying source code: PHP has a built-in syntax highlighter with two aliased functions, show_source() and highlight_file(), which take a file name as the argument. Code is colored depending on values set in php.ini (coloring strings, comments, keywords, background, and html.