25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PHP</strong> Basics ” 11<br />

• When converted to a number or a string, a Boolean becomes 1 if it is true, and<br />

0 otherwise.<br />

Compound Data Types<br />

In addition to the scalar data type that we have just examined, <strong>PHP</strong> supports two<br />

compound data types—so called because they are essentially containers of other<br />

data:<br />

• Arrays are containers of ordered data elements; an array can be used to store<br />

and retrieve any other data type, including numbers, Boolean values, strings,<br />

objects and even other arrays. They are discussed in the Arrays chapter<br />

• Objects are containers of both data and code. They form the basis of Objectoriented<br />

Programming, and are also discussed in a separate chapter called Object<br />

Oriented Programming in <strong>PHP</strong>.<br />

Other Data Types<br />

In addition to the data types that we have seen so far, <strong>PHP</strong> defines a few additional<br />

types that are used in special situations:<br />

• NULL indicates that a variable has no value. A variable is considered to be NULL<br />

if it has been assigned the special value NULL, or if it has not yet been assigned<br />

a value at all—although in the latter case <strong>PHP</strong> may output a warning if you<br />

attempt to use the variable in an expression.<br />

• The resource data type is used to indicate external resources that are not used<br />

natively by <strong>PHP</strong>, but that have meaning in the context of a special operation—such<br />

as, for example, handling files or manipulating images.<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

Converting Between Data Types<br />

As we mentioned, <strong>PHP</strong> takes care of converting between data types transparently<br />

when a datum is used in an expression. However, it is still possible to force the conversion<br />

of a value to a specific type using type conversion operators. These are sim-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!