Chapter 9. DATA FUNCTIONS
Data Types, Constants, and Variables.....................................................
Arrays
Hashing
Strings
Encoding and Decoding.................................................................................
Encryption
Regular Expressions........................................................................................
Perl-Compatible Regular Expressions......................................................
The functions in this chapter manipulate data. They check the values of variables. They
transform one type of data into another. They also deal with arrays. You may find it
useful to turn back to Chapter 2, "Variables, Operators, and Expressions,"
and read the discussion on data types and variables.
Data Types, Constants, and Variables
These functions check the status of a variable, change its type, or return a value as a
particular data type.
boolean define(string name, value, boolean
non_case_sensitive)
The define function creates a constant, which is essentially a variable that may be set
only once. The value argument may be a string, integer, double, or boolean. It may not
be an array or object. The non_case_sensitive argument is optional. By default,
constants are case sensitive, which is the same as with variables.
If the constant cannot be created for some reason, FALSE will be returned. If you wish to
check that a constant is defined, use the defined function.
It is customary to name constants using all uppercase letters, as is the practice in C. This
makes them stand out among other identifiers.
Because PHP allows for unquoted string literals, it is possible to write code that uses
constants that do not exist, yet produces no error. When you are using constants to hold
strings to be displayed on the page, this is simply an annoyance, because you can see the
error right away. When used for values not displayed, it can be a frustrating source of