COMPUTER LEARNING CENTER
WWW.HUUKHANG.COM
<BODY>
<h4>Variable</h4>
<?php
$sotrang=10;
$record=5;
$check = true;
$strSQL="select * from tblCustomers";
$myarr = array("first", "last", "company");
$myarrs[2];
$myarrs[0]="Number
0";
$myarrs[1]="Number
1";
$myarrs[2]="Number
2";
echo
$myarr[1];echo
"<br>";
echo
$myarrs[2];
?>
</BODY>
</HTML>
3.
KIEÅU DÖÕ LIEÄU
Baûng caùc kieåu döõ lieäu thoâng thöôøng
Boolean True hay false
Integer giaù trò lôùn nhaát xaáp xæ 2 tyû
Float ~1.8e308 goàm 14 soá leõ
String Löu chuoãi kyù töï chieàu daøi voâ haïn
Object Kieåu ñoái töôïng
Array Maûng vôùi nhieàu kieåu döõ lieäu
3.1.
Thay ñoåi kieåu döõ lieäu
Ñeå thay ñoåi kieåu döõ lieäu, baïn coù theå söû duïng caùch eùp kieåu nhö trong caùc ngoân ngöõ laäp
trình C hay Java. Chaúng haïn, khai baùo eùp kieåu nhö ví duï 2-2 (box.php):
<HTML>
<HEAD>
<TITLE>::Welcome to PHP</TITLE>
</HEAD>
<BODY>
<h4>Variable</h4>
<?php
$i="S10A";
echo
$i+10;
echo
"<br>";
$i="10A";
$j=(float)$i;
$j+=10;
echo
$i;
echo
"<br>";
echo
$j;
echo
"<br>";
$q=12;$p=5;
echo
"Amount:
".(float)$q/$p;
?>
</BODY>
</HTML>
Giaùo vieân: Phaïm Höõu Khang