Apa itu PHP :
PHP is a server scripting language,
and a powerful tool for making dynamic and interactive Web pages.
PHP is a widely-used, free, and
efficient alternative to competitors such as Microsoft's ASP.
Source :
1.1 Penerapan php dalam kode html
<!DOCTYPE html>
<html>
<body>
<?php
$ = 5;
$y = 4;
echo $x + $y;
<html>
<body>
<?php
$ = 5;
$y = 4;
echo $x + $y;
Echo “ini tampil ke layar”;
Echo “Ini tampil ke layar ”.$x+$y.
”dan nilai ini”;
?>
</body>
</html>
</body>
</html>
1.2 Contoh –contoh script php
1. Contoh 1
<!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
2. Contoh 2
$x = 5;
$y = 4;
echo $x + $y;
$y = 4;
echo $x + $y;
Echo “”;
3. Contoh 3
<?php
$x = 5;
$y = 10;
function myTest() {
global $x, $y;
$y = $x + $y;
}
myTest();
echo $y; // outputs 15
?>
$x = 5;
$y = 10;
function myTest() {
global $x, $y;
$y = $x + $y;
}
myTest();
echo $y; // outputs 15
?>
0 komentar:
Posting Komentar