Creating Scripts


 <?php     .     .     . ?> 

You usually surround a PHP script with the markup <?php...?>, which tells a PHP-enabled server that you're going to be using PHP. A number of keywords, which appear in Table A-1, are reserved for PHP's own use.

Table A-1. PHP Keywords

__CLASS__

__FILE__

__FUNCTION__

__LINE__

__METHOD__

and

default

endif

global

print

array

die

endswitch

if

require

as

do

endwhile

include

require_once

break

echo

eval

include_once

return

case

else

exception

isset

static

cfunction

elseif

exit

list

switch

class

empty

extends

new

unset

const

enddeclare

for

old_function

use

continue

endfor

foreach

or

while

declare

endforeach

function

php_user_filter

xor


Scripts are composed of PHP statements, which end with a semicolon in PHP, unless they're compound statements surrounded with curly braces, { and } . Here's an example of both:

 <?php     if ($test) {         echo "No worries.";     } ?> 

You can also interleave PHP with HTML; here's an example:

 <?php     if ($test) { ?>     <b>No worries.</b> <?php     } else { ?>     <b>Could be a problem.</b> <?php     } ?> 



    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net