PHP Syntax Overview

Basic PHP Syntax

Script PHP di awali dengan <?php dan di tutup dengan ?>

<?php
   // PHP code here
?>

extension untuk file PHP adalah .php, contoh simple program PHP mencetak Hello World di browser :

<!DOCTYPE html>
<html>
 <body>
  <h1>My first PHP page</h1>
  <?php
     echo "Hello World!";
  ?>
</body>
</html>

PHP Case Sensitivity

PHP tidak ada keywords seperti (if, else, while, echo dll), class, function

<!DOCTYPE html>
<html>
 <body>
  <?php
    ECHO "Hello World!<br>";
    echo "Hello World!<br>";
    EcHo "Hello World!<br>";
 ?>
</body>
</html>
Hello World!
Hello World!
Hello World!

PHP Comments

Komentar dalam kode PHP adalah baris yang tidak dieksekusi sebagai bagian dari program.

<!DOCTYPE html>
<html>
<body>
  <?php
     // This is a single-line comment
    # This is also a single-line comment
  ?>
</body>
</html>

atau kita bisa meyisipkan koment dalam line script

<!DOCTYPE html>
<html>
<body>

<?php
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>

</body>
</html>

hyvercode

Leave a Reply

Your email address will not be published. Required fields are marked *