Merupakan operator yang digunakan untuk memanipulasi variabel itu sendiri seperti menambah atau memasukan sebuah nilai ke variabel. Operator penugasan dasar dalam PHP adalah "=". Ini berarti bahwa operand kiri akan diatur ke nilai ekspresi penugasan di sebelah kanan. Berikut contoh operator penugasan di PHP :
- Operand kiri akan diatur ke nilai ekspresi di sebelah kanan.
- Penjumlahan
- Pengurangan
- Perkalian
- Pembagian
- Modulus
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; | |
?> |
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 = 20; | |
$x += 100; | |
echo $x; | |
?> |
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 = 50; | |
$x -= 30; | |
echo $x; | |
?> |
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; | |
$x *= 5; | |
echo $x; | |
?> |
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; | |
$x /= 5; | |
echo $x; | |
?> |
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 = 15; | |
$x %= 4; | |
echo $x; | |
?> |