This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Penggunaan angka dalam variabel yang salah | |
| $12345 = "contoh1"; | |
| $2morow = "contoh2"; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // cara 1 menggunakan keyword const | |
| const nama = "Belajar Konstanta"; | |
| echo nama; // kata yang akan muncul adalah Belajar Konstanta | |
| //cara 2 menggunakan keyword define | |
| define ("nama" , "Belajar Konstanta"); | |
| echo nama; // kata yang akan muncul adalah Belajar Konstanta | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Semua Kode di bawah ini adalah Ekspresi PHP | |
| $nilai1 = "87"; | |
| $nilai2 = "92"; | |
| $nilai3 = "89"; | |
| echo $nilai1 + $nilai2 * $nillai3; | |
| // Contoh diatas merupakan suatu bentuk ekspresi yang menghasilkan nilai 87 | |
| // Angka 87, 92 dan 89 disebut sebagai operand | |
| // Tanda + dan * disebut sebagai operator. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| $y = 6; | |
| echo $x + $y; // 10 + 6 = 16 adalah hasilnya | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| $y = 6; | |
| echo $x - $y; // 10 - 6 = 4 adalah hasilnya | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| $y = 6; | |
| echo $x * $y; // 10 * 6 = 60 adalah hasilnya | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| $y = 3; | |
| echo $x / $y; # 10/3 = 3.3333333333333 adalah hasilnya | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 100; | |
| $y = 8; | |
| echo $x % $y; // Hasilnya 4 | |
| /* Sisa hasil bagi 100 oleh 8 adalah 4 | |
| Logikanya 8 * 12 = 96, sisa 4 dari 100 dan tidak bisa di bagi 8 lagi */ | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 8; | |
| $y = 4; | |
| echo $x ** $y; | |
| // Hasilnya adalah 4096 | |
| // Hasil dari 8 pangkat 4 atau 8 * 8 * 8 * 8 | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $x = 10; | |
| echo $x; | |
| ?> |