Jadi klu di PHP variable static itu tetap ada atau tidak dibuang oleh program ketika suatu fungsi sudah selesai dieksekusi. Jadi nilainya variable static itu tetap sekalipn fungsinya udah selese dipanggil. Terus untuk mendefinisikan variable static, tinggal nambain kata STATIC didepan variablenya. Contoh sederhana seperti terlihat pada program di bawah :
Hasilnya :
Seperti terlihat, didalam fungsi staticExample dibuat variable static dengan nama Hisoka, kemudian variabel static ini diincrement untuk setiap pemanggilan fungsi. Pemanggilan pertama nilainya berubah menjadi 18. Ini wajar soalnya nilai awalnya adalah 17. Tetapi pada pemanggilan berikutnya variabel Hisokanya tetap nyimpen nilai dari increment pemanggilan fungsi sebelumnya. Makanya nilainya menjadi 19, 20, dan 21, dan tidak tetap pada nilai 18. Nah keliatan fungsi STATIC disini hehehe... :-D
Tuesday, August 18, 2015
Friday, August 14, 2015
Running PHP Program Using Command Prompt
We can run php program by using command prompt too. But there are some differences if we are using XAMP beside cmd. In cmd, html codes can't be identified, so just don't use html syntax if you are gonna use cmd for compiling your php program. Okieee... let's just use pure php style as shown below :
Save above code, then open command prompt on the same directory where We save our php code. Theen type "php yourPHPcode.php" in command prompt :
Save above code, then open command prompt on the same directory where We save our php code. Theen type "php yourPHPcode.php" in command prompt :
Subscribe to:
Posts (Atom)



