RUE
PHP. , Foreach, Perl.
-, .. PHP.
Hello world PHP:
lt ;? php Hello, world! raquo ;;
? gt;
:
lt;?= Hello, world! ? gt;
lt;? =. ,, Lt ;? php? gt ;. ,,. PHP- HTML-,,:
lt; html gt;
lt; head gt;
lt; title gt; PHP lt;/title gt;
lt;/head gt;
lt; body gt;
lt ;? php echo Hello, world! raquo ;;? gt;
lt;/body gt;
lt;/html gt;
lt ;? php? gt ;,, lt; ?? gt; lt; script language=«php» gt; lt;/script gt ;. , 6.0 ASP lt; %% gt; ( Lt; ?? gt; lt; %% gt; php.ini).
$,. ,.. ,, Heredoc- (, lt; lt; lt;). , HTML. (;), If/else [11].
, ( amp;).:(/ * * /), C ++ (//) UNIX (#). ,,. (, PHP).
:
· (integer),
· (float, double),
· (boolean),
· (string),
· NULL.
:
· «» (resource),
· (array),
· (object),
:
· mixed,
· number (integer float),
· callback (string),
· void.
(integer) PHP (, 32-,,? 2147483648 2147483647). ,. (double) (32 ± 1.7? 10? 308 ± 1.7? 10 + 308). (boolean), TRUE («») FALSE («»). 0,, «0», NULL FALSE. TRUE.
NULL. NULL. NULL, NULL,, unset ().
«» (resource). ,,,,,, ..
(array). ,.. php-,,,. for foreach. ,,,.
PHP callback. 5.3,,:
function ($ args .. $ argsN) use ($ ctxVar, $ ctxVar1) {definition;}
:
· ();
· - ();
· -, - ().
is_callable ($ var)
$,..:
$ a= I am a raquo ;;// $ A $ a;// $
$ b= a raquo ;; $$ b;// $ ($ $ B)
echo $ { a };// $ A_name ();// Function_name
$ c= function_name raquo ;;
$ c ();// Function_name,
$ d= Class_name raquo ;;
$ obj=new Class_name;// Class_name
$ obj=new $ d ();// Class_name
$ obj- gt; b;// B
$ obj- gt; c ();// C ()
$ obj- gt; $ b;// A, $ b= a
$ obj- gt; $ c ();// Function_name (), $ c= function_name
PHP echo print (print),..
(. Superglobal arrays) PHP, global. (GET-, POST, ..).
, $ GLOBALS $ _REQUEST,, 5.3. (5.4.0). , $ _GET [ Laquo; year ] $ HTTP_GET_VARS [ year ] (: «») [12].
$ GLOBALS
().
$ _ SERVER (- $ HTTP_SERVER_VARS)
,.
$ _ ENV (. $ HTTP_ENV_VARS)
(. Environment variables). ,.
$ _ GET (. $ HTTP_GET_VARS)
GET-, URI «?».
$ _ POST (. $ HTTP_POST_VARS)
HTML- POST. name (,, -, ..) HTML -.
$ _ FILES (. $ HTTP_POST_FILES)
POST. , «Name»,,,:
· [ name ] -.
· [ type ] - MIME-. PHP,,.
· [ size ] -.
· [ tmp_name ] -. move_uploaded_file. PHP.
· [ error ] -. , 0 (UPLOAD_ERR_OK).
$ _ COOKIE (. $ HTTP_COOKIE_VARS)
.
$ _ REQUEST
$ _GET, $ _POST, $ _COOKIE. PHP 4.1 $ _FILES.
$ _ SESSION (. $ HTTP_SESSION_VARS)
.-,.
PHP class. (public,), (protected) (private). PHP -, (extends). (Implements). ,. ,. parent.
5.4.0 (. trait). (. Mixins),.... «».
PHP (. magic methods),. (__construct (), 5.0,) (__des...