Contoh Variabel Scope dalam Fungsi PHP
Pengertian Variabel Scope Variabel Scope (atau ruang lingkup variabel) adalah jangkauan kode program dimana perintah program masih bisa mengakses sebuah variabel. Contoh Variabel Scope dalam Fungsi PHP Untuk memahami konsep variabel scope, berikut adalah contoh kode program dalam PHP: <?php $a = 5; function coba() { $a=10; $b=7; } // pemanggilan fungsi coba() coba(); echo $a; // 5 echo $b; // error:notice ?> Contoh lainnya, perhatikan kode program berikut ini: <?php $b = 7; function coba() { $a=10; echo $a; echo $b; } coba(); ?> [...]