Specifications

Advanced PHP Techniques
P
ART IV
448
Some useful PHP functions and features do not fit into any particular category. This chapter
will explain these features.
Well look at
Using magic quotes
Evaluating strings with eval()
Terminating execution: die and exit
Serialization
Getting information about the PHP environment
Temporarily altering the runtime environment
Loading PHP extensions
Source highlighting
Using Magic Quotes
You have probably noticed that you need to be careful when using quote symbols ( and ) and
back slashes (\) within strings. PHP will get confused by an attempted string statement like
echo “color = “#FFFFFF””;
and give a parse error. To include quotes inside a string, use the quote type that is different
from the quotes enclosing the string. For example
echo “color = ‘#FFFFFF’”;
or
echo ‘color = “#FFFFFF”’;
will both be valid.
The same problem occurs with user input, as well as input and output to, or from, other
programs.
Trying to run a mysql query like
insert into company values (‘Bob’s Auto Parts’);
will produce similar confusion in MySQLs parser.
We have already looked at the use of addslashes() and stripslashes() that will escape out
any single quote, double quote, backslash and NUL characters.
26 7842 CH21 3/6/01 3:41 PM Page 448