function in php

23
AUTHOR: TRUONG TOAN THINH Fundamental PHP

Upload: traipham

Post on 01-Oct-2015

224 views

Category:

Documents


0 download

DESCRIPTION

cau truc php

TRANSCRIPT

Fundamental PHP

Author: truong toan thinhFundamental PHPFunction in PHPUsing require() & include()User defined functionFunction argumentsReturning valuesVariables functionsInternal functionsUsing require() & include()require()is identical toinclude()except upon failure it will also produce a fatalE_COMPILE_ERRORlevel error. In other words, it will halt the script whereas include()only emits a warning (E_WARNING) which allows the script to continue.

vars.php

test.phpMicrosoft Internet Explorerx-FileEditViewFavoritesToolHelpAddressGohttp://localhost/myweb/test.phpA A green appleUsing require() & include()

test.phpMicrosoft Internet Explorerx-FileEditViewFavoritesToolHelpAddressGohttp://localhost/myweb/test.phpA

include unknown.phprequire unknown.php

User defined functionA function may be defined using syntax such as the following:

function namekey wordArgument listUser defined functionFunction names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.Functions need not be defined before they are referenced,exceptwhen a function is conditionally defined as shown in the two examples below.When a function is defined in a conditional manner such as the two examples shown. Its definition must be processedpriorto being called.User defined function