.


:




:

































 

 

 

 





 

. , , -, , . - PHP. PHP -. TIOBE, , 2012 PHP 6 . , PHP, Facebook, , Wikipedia .

: - PHP.

:

- PHP;

- , ;

- .


 

PHP

 

1994 , : , " ". , (FI - form interpretation), . PHP⁄FI. , PHP⁄FI. 1997 50000 Web- PHP⁄FI - , .. Zeev Suraski Andi Gutmans, 3.0. 3.0 1998 , Web-, , SNMP (Simple Network Management Protocol - ) IM (Internet Message Access Protocol - ).

PHP ( "PHP: Hypertext Preprocessor") - () , Web HTML[1]. -.

-.

:

- POST GET-,

- ;

-

(MySQL, MySQLi, SQLite, PostgreSQL, Oracle (OCI8), Oracle, Microsoft SQL Server, Sybase, ODBC, mSQL, IBM DB2, Cloudscape Apache Derby, Informix, Ovrimos SQL, Lotus Notes, DB++, DBM, dBase, DBX, FrontBase, FilePro, Ingres II, SESAM, Firebird / InterBase, Paradox File Access, MaxDB, PDO);

- HTTP-;

- HTTP-;

- cookies ;

- , .

- , ;

- XForms;

PHP LAMP - - (Linux, Apache, MySQL, PHP). PHP C. , foreach, Perl. - , . . PHP.

 

 


 

 

PHP , , [2]. php, , . , :

<?php
function myrow($id, $data)
{
return "<tr><th>$id</th><td>$data</td></tr>\n";
}
$arr = get_defined_functions();
print_r($arr);
?>

. internal user. user , internal php.

Array([internal] => Array ([0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen... [750] => bcscale [751] => bccomp) [user] => Array ([0] => myrow))

, php, C. , - . , [2].

:

- ;

- ;

- ;

- ;

- .

1.

2.

PHP . . PHP . . gettype() settype(). [3]

- Gettype .

: string gettype (mixed $var). PHP- var. is_*.

gettype()

<?php
$data = array(1, 1., NULL, new stdClass, 'foo');
foreach ($data as $value) {
echo gettype($value), "\n";
}
?>

- Settype .

: bool settype (mixed &$var, string $type). TRUE FALSE .

settype():

<?php
$foo = "5bar"; //
$bar = true; //
settype($foo, "integer"); // $foo 5 ()
settype($bar, "string"); // $bar "1" ()
?>

. isset().

- isset , NULL.

: bool isset (mixed $var [, mixed $... ]). unset(), . isset() FALSE, NULL. , NULL- ("\0") PHP NULL. , , isset() TRUE , . , .

 

 

. , int float.
:

- ;

- ;

- ;

- ;

- ;

- ( ).

 

 

:

- Abs .

: number abs (mixed number). number. number float, float, integer.

abs():

<?php
$abs = abs(-4.2); // $abs = 4.2; (double/float)
$abs2 = abs(5); // $abs2 = 5; (integer)
$abs3 = abs(-5); // $abs3 = 5; (integer)
?>

- floor - .

: float floor (float $value). , value . value, . floor() float, .. float , integer.

floor():

<?php
echo floor(4.3); // 4
echo floor(9.999); // 9
echo floor(-3.14); // -4
?>

- ceil .

: float ceil (float $value). value. float.

ceil():

<?php
echo ceil(4.3); // 5
echo ceil(9.999); // 10
echo ceil(-3.14); // -3
?>

- max .

: mixed max (number arg1, number arg2 [, number...]) mixed max (array numbers). , max() . 2 , max() .

: PHP , , 0, , , . , 0, max() ( ).

max():

<?php
echo max(1, 3, 5, 6, 7); // 7
echo max(array(2, 4, 5)); // 5
// 'hello' 0.
// , ,
echo max(0, 'hello'); // 0
echo max('hello', 0); // hello
echo max('42', 3); // '42'
// 0 , -1,

'hello'.
echo max(-1, 'hello'); // hello
// , - max


$val = max(array(2, 2, 2), array(1, 1, 1, 1)); // array(1, 1, 1, 1)
// - max


// , 2 == 2, 4 < 5
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)
// ,


$val = max('string', array(2, 5, 7), 42); // array(2, 5, 7)
?>

- rand - .

: int rand ([int min, int max]). min max, 0 RAND_MAX. , 5 15 (), rand (5, 15).

rand():

<?php
echo rand(). "\n";
echo rand(). "\n";
echo rand(5, 15);
?>

- sqrt .

: float sqrt (float $arg). arg NAN .

sqrt():

<?php
//
echo sqrt(9); // 3
echo sqrt(10); // 3.16227766...
?>

 





:


: 2015-11-23; !; : 587 |


:

:

.
==> ...

1902 - | 1680 -


© 2015-2024 lektsii.org - -

: 0.03 .