For instance, you can effect numerous changes to a value on the same line
by stacking functions in a particular order. The following example produces a string
of five alphanumeric characters such
as a3jh8:
$randomString = substr(md5(microtime()), 0, 5);
PHP is a loosely typed language, meaning there is no need to explicitly create, typecast,
or destroy a variable, although you are not prevented from doing so. PHP handles
such matters internally, creating variables on the fly as they are called in a script,
and employing a best-guess formula for automatically typecasting variables. For
instance, PHP considers the following set of statements to be perfectly valid:
8 CHAPTER 1 ?– I NTRODUCING PHP
$number = "5"; // $number is a string
$sum = 15 + $number; // Add an integer and string to produce integer
$sum = "twenty"; // Overwrite $sum with a string.
?>
PHP will also automatically destroy variables and return resources to the system
when the script completes. In these and in many other respects, by attempting to
handle many of the administrative aspects of programming internally, PHP allows
the developer to concentrate almost exclusively on the final goal, namely a working
application.
Power
PHP developers have more than 180 libraries at their disposal, collectively containing
well over 1,000 functions. Although you??™re likely aware of PHP??™s ability to interface
with databases, manipulate form information, and create pages dynamically, you
might not know that PHP can also do the following:
??? Create and manipulate Adobe Flash and Portable Document Format (PDF) files
??? Evaluate a password for guessability by comparing it to language dictionaries
and easily broken patterns
??? Parse even the most complex of strings using the POSIX and Perl-based regular
expression libraries
??? Authenticate users against login credentials stored in flat files, databases, and even
Microsoft??™s Active Directory
??? Communicate with a wide variety of protocols, including LDAP, IMAP, POP3,
NNTP, and DNS, among others
??? Tightly integrate with a wide array of credit-card processing solutions
And this doesn??™t take into account what??™s available in the PHP Extension and
Application Repository (PEAR), which aggregates hundreds of easily installable open
source packages that serve to further extend PHP in countless ways.
Pages:
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81