05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

change. Constants are referred to by their identifiers and are set using the define( )<br />

function:<br />

define('PUBLISHER', "O'Reilly & Associates");<br />

echo PUBLISHER;<br />

Keywords<br />

A keyword is a word reserved by the language for its core functionality—you cannot<br />

give a variable, function, class, or constant the same name as a keyword. Table 2-1<br />

lists the keywords in <strong>PHP</strong>, which are case-insensitive.<br />

Table 2-1. <strong>PHP</strong> core language keywords<br />

and $argc $argv as<br />

break case cfunction class<br />

continue declare default die<br />

do E_ALL echo E_ERROR<br />

else elseif empty enddeclare<br />

endfor endforeach endif endswitch<br />

E_PARSE eval E_WARNING exit<br />

extends FALSE for foreach<br />

function $HTTP_COOKIE_VARS $HTTP_ENV_VARS $HTTP_GET_VARS<br />

$HTTP_POST_FILES $HTTP_POST_VARS $HTTP_SERVER_VARS if<br />

include include_once global list<br />

new not NULL old_function<br />

or parent <strong>PHP</strong>_OS $<strong>PHP</strong>_SELF<br />

<strong>PHP</strong>_VERSION print require require_once<br />

return static stdClass switch<br />

$this TRUE var virtual<br />

while xor _ _FILE_ _ _ _LINE_ _<br />

_ _sleep _ _wakeup $_COOKIE $_ENV<br />

$_FILES $_GET $_POST $_SERVER<br />

In addition, you cannot use an identifier that is the same as a built-in <strong>PHP</strong> function.<br />

For a complete list of these, see Appendix A.<br />

Data Types<br />

<strong>PHP</strong> provides eight types of values, or data types. Four are scalar (single-value) types:<br />

integers, floating-point numbers, strings, and booleans. Two are compound (collection)<br />

types: arrays and objects. The remaining two are special types: resource and<br />

NULL. Numbers, booleans, resources, and NULL are discussed in full here, while<br />

strings, arrays, and objects are big enough topics that they get their own chapters<br />

(Chapters 4, 5, and 6).<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

Data Types | 23

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

Saved successfully!

Ooh no, something went wrong!