-

 -

  •     - - . : Internet Explorer 6, Fire Fox 1.5, Opera 9.5, Safari 3.1.1 JavaScript.

 -

   Net-man

 - e-mail

 

 -

 LiveInternet.ru:
: 20.04.2010
: 814
: 5985
: 11575

:


PHP: PHP,

, 04 2011 . 22:24 +

PHP ():

:

  • boolean ( )
  • integer ( )
  • float ( 'double')
  • string ()

:

  • array ()
  • object ()

:

  • resource ()
  • NULL ( )

:

  • mixed ( )
  • number ()
  • callback ( )

PHP.

Boolean ( )

. - TRUE, FALSE. PHP 4.

, TRUE FALSE. -.

$x = True; // $x TRUE
?>

, , .

// == ,
//
if ($action == "_") {
echo " 1.23";
}

// ...
if ($show_separators == TRUE) {
echo "


\n";
}

// ...
if ($show_separators) {
echo "


\n";
}
?>

integer ( )

Z = {..., -2, -1, 0, 1, 2, ...}, 32 ( –2 147 483 648 2 147 483 647).

, , (- +).

, 0 (), 0x.

$a = 1234; //
$a = -123; //
$a = 0123; // ( 83 )
$a = 0x1A; // ( 26 )
?>

float ( )

Double - ( ).

( ) :

$a = 1.234;
$b = 1.2e3;
$c = 7E-10;
?>

string ()

PHP - . , , . , . .

, .

:


$a = " , ";
echo $a; // ' , '
?>

array ()

PHP - , .

() . .

PHP . :

()

, , - :

php
//
$names[0]="";
$names[1]="";
$names[2]="";
$names[3]="";
// : names - , 0, 1, 2, 3 -
?>

PHP , . : , .

, , . . :

php
//
$names[""]="";
$names[""]="";
$names[""]="";
// : -
// , -
?>

PHP array(). . :

php // $A["Ivanov"] = array("name"=>" ..", "age"=>"25", "email"=>"ivanov@mail.ru"); $A["Petrov"] = array("name"=>" ..", "age"=>"34", "email"=>"petrov@mail.ru"); $A["Sidorov"] = array("name"=>" ..", "age"=>"47", "email"=>"sidorov@mail.ru"); ?>

Pascal C.

object ()

- . , , ->, .

new, .

class foo
{
function do_foo()
{
echo "Doing foo.";
}
}

$bar = new foo;
$bar->do_foo();
?>

PHP

resource ()

- , . .

NULL ( )

NULL , . NULL - NULL ( ).

NULL :

  • NULL;

  • - ;

  • unset()

$var = NULL;
?>

is_null() unset().

mixed ( )

mixed , ( ) .

gettype(), , PHP, str_replace() .

number ()

number , integer, float.

callback ( )

, call_user_func() usort() callback-. Callback- , , .

PHP- . array(), echo(), empty(), eval(), exit(), isset(), list(), print() unset().

callback :


// callback
function my_callback_function() {
echo 'hello world!';
}
call_user_func('my_callback_function');

// callback-
class MyClass {
function myCallbackMethod() {
echo 'Hello World!';
}
}

//
call_user_func(array('MyClass', 'myCallbackMethod'));

//
$obj = new MyClass();
call_user_func(array(&$obj, 'myCallbackMethod'));
?>



: http://php.su


PHP
:  

1

: [1] []
 

:
: 

: ( )

:

  URL