<?php
function tester()
{
$text = " , . ";
print $text;
}
tester();
?>
, $text .
return. " ". , .
4.3.2
function mysqrt($a)
{
return $a*$a;
}
echo mysqrt(4);
16.
, . . .
.5.
, . , . .
, , . ? , , , . , . , , .
. () . . . , , 1, 2 .. - , .
array(). .
array()
5.1 array()
<?php
$students = array("Ira","Vadim","Alex","Ann");
print $students[0];
?>
. array(), . ($students), . print() 0 ( , ).
, , . , , . , Ira 0, Vadim 1, Alex 2, Ann 3. , 0, Ira.
|
|
, , () . . $students .
5.2
<?php
$students[] = "Ira";
$students[] = "Vadim";
$students[] = "Alex";
$students[] = "Ann";
print $students[0];
?>
, . PHP , , .
5.2 5.1.
, . 5.3 array() .
5.3
<?php
$students = array("Ira","Vadim","Alex","Ann");
$students[] = "Max";
print $students[4];
?>
, 4 Max. , , .
. . , . , . , . , . 5 6 , 50. . , . . .
, . array().
array ()
5.4 array()
<?php
$tel = array(
"Max Koshelev" => "580-46-82",
"Ann Reish" => "589-90-34",
"Pashsa Golikov" => "480-57-58"
);
print $tel["Max Koshelev"];
?>
array(), (Max Koshelev, Ann Reish, Pashsa Golikov), (580-46-82, 589-90-34, 480-57-58) . $tel . . , . ( , ). - 580-46-82.
|
|
/ , , .
5.5
<?php
$tel["Max Koshelev"] = "580-46-82";
$tel["Ann Reish] = "589-90-34";
$tel["Pashsa Golikov"] = "480-57-58";
print $tel["Max Koshelev"];
?>
$tel.
. , , . count(). .