Before writing our very first Php program a short explanation about Php tags will be needed.
Php code can be freely mixed with html codes.
When html code ends and php code started you have to type in the "php start tag".
Also when the php code ends and html code started again, the "php end tag" have to be type in again.
Various pairs of "php start tag" and "php end tag" are shown below:-
Tag Style
Start Tag
See below how these 4 pairs of Php Tag are used:-
Now lets write our first php program.
Open MS Notepad and type the code shown below. Observe carefully how the start and end tags were used.
<html> <head> <title>hello</title> </head> <body> <?php echo "Hello World!"; ?> </body> </html>
Save as "hello.php" in folder "www" shown below.
Now close the notepad and open the browser.
In the address box type in http://localhost/hello.php and click enter.
If you have done everything properly, you will see "Hello World!" as shown below.
Congratulation, you have written your first php program successfully.
ကၽြန္ေတာ္ တို႔ရဲ့ ပထမဆံုး Php program ကို မေရးမွီ Php tags ေတြ အၾကာင္း နည္းနည္း ရွင္းျပ လို ပါတယ္။
Php code ေတြ ကို html code ေတြနဲ ့ေရာ ေႏွာ္း ေရး လို ့ရပါ တယ္။
Html code ဆံုး ျပီး php code စေတာ့ မယ္ ဆို ရင္ "php start tag" ကို ရိုက္ရ ပါတယ္။
ေနာက္ php code ဆံုးျပီး html code ျပန္စ ေတာ့ မယ္ ဆိုရင္လည္း "php end tag" ကို ရိုက္ရပါတယ္။
အသံုး မ်ားတဲ့ "php start tag" နဲ ့ "php end tag" တို ့ကို ေအာက္ မွာ ေဖၚျပထားပါတယ္။
Php Tag ၄ မိ်ဳး အသံုး ခ်ပံုကို ေအာက္တြင္ ၾကည့္ပါ:-
အခု ကၽြန္ေတာ္ တို ့ရဲ့ ပ႒မ ဆံုး Php Program ကိုေရး ၾကည့္ၾက ရေအာင္။
MS Notepad ကို ဖြင့္ၿပီး ေအာက္ မွာ ေဖၚျပ ထားတဲ့ code ကိုရိုက္ ထည့္ပါ၊ အနီ နဲ ့ေရး ထားတဲ့ Php Tag အသံုး ျပဳပံု ကို မွတ္မွတ္ သားသား ေလ့လာ ပါ၊ ေနာင္ကို ခဏခဏ ေတြ ့ေန ရမွာ ျဖစ္ပါတယ္။
ျပီးလွ်င္ hello.php ဆိုတဲ့ file name နဲ ့ေအာက္ ေဖၚျပပါ "www" folder တြင္ save လုပ္ပါ။
Notepad ကိုပိတ္ျပီး Browser ကိုဖြင့္ပါ။ Address Box တြင္ http://localhost/hello.php ဟု ရိုက္ သြင္းျပီး enter ကို ႏွိပ္ ပါ။ သင္၏ လုပ္ေဆာင္ ခ်က္မ်ား မွန္ကန္ပါ က ေအာက္ ပါအတိုင္း ေတြ႔ ့ရပါမည္။
ဂုဏ္ယူ ပါတယ္ သင္၏ ပ႒မဆံုး Php Program ေအာင္ျမင္ သြားပါၿပီး။
Leave your comment
Name
You can type in both English and Myanmar (Use Zawgyi Font)
Leave your comment