Myanmar IT Resource Forum
Myanmar IT Resource Forum
Myanmar IT Resource Forum

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1PHP lesson for self-study Empty PHP lesson for self-study 20th November 2009, 9:14 pm

ogre

ogre
Moderator



Moderator
Using the function 'echo'

ပရိုဂရမ္ တခုကို run လုပ္တဲ့ အခါ
ဘယ္ေလာက္ ပဲ ရွုပ္ေထြး တဲ့
ပရိုဂရမ္ ျဖစ္ေန ပါေစ၊ ေနာက္ဆံုး မွာ ရလာဘ္
အေျဖ တခု ကို return ျပန္ ပို႔ေပး မွာ
ျဖစ္ ပါတယ္။

ဒီအခါ မွာ programmer ဟာ ေအာက္ေဖၚျပ ပါ လုပ္ေဆာင္ ခ်က္ တခုခု ကို အမ်ား အားျဖင့္
ေဆာင္ရြက္ မွာျဖစ္ ပါတယ္။


  • ျပန္ရတဲ့ return ကို file အခု အေနနဲ႔ save လုပ္ျခင္း
  • ကြန္ပ်ဴတာ monitor screen ေပၚမွာ user ေတြ ျမင္ရေအာင္ ေရးျပျခင္း
  • User ေတြ ၾကားႏိုင္ ေအာင္ speaker သို႔မဟုတ္ earphone သို႔ အသံအျဖစ္ output
    လုပ္ေပး ျခင္း။


ေလာေလာဆည္ ေတာ့ monitor screen ေပၚမွာ user ေတြျမင္ ရေအာင္ ေရးျပ တဲ့
လုပ္ငန္း ကိုပဲ ေလ့လာၾက ရေအာင္း.

PHP ဟာ echo ဆိုတဲ့
function ကိုသံုး ၿပီး users ျမင္ရ ေအာင္ monitor screen ေပၚ မွာ ေရး
ပါတယ္။

echo အျပင္ screen ေပၚမွာ ေရးခိုင္း
ႏိုင္တဲ့ အျခား function ေတြ ရွိေန ေပမဲ့ ဒီမွာေတာ့ echo
တခုထဲ ကို ပဲ ေလ့လာ သြားမွာ ျဖစ္ ပါတယ္။

အလြယ္ဆံုး နည္းလမ္း ကေတာ့ အမွားမရွိ ပဲ run လုပ္ႏိုင္တဲ့ working example တခု
ကို ေလ့လာ ျခင္း ပါဘဲ။

ေအာက္မွာ ေဖၚျပ ထားတဲ့ code ကို copy လုပ္ၿပီး notepad တခု မွာ paste လုပ္ပါ။
ၿပီးရင္ echo_example.php ဆိုတဲ့ file name နဲ႔ 'www' folder မွာ save လုပ္ပါ။.
PHP lesson for self-study Folder10

Code:
[color=#000000][b]



[/b]



[b][/b]
error_reporting(E_WARNING);
[color=#008000]//just put above line , don't ask anything
//concentrate on usage of echo[/color]


[b][color=#ff0000]echo[/color][/b] "Hello World ";

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[b][color=#ff0000]echo[/color][/b] "This spans
multiple lines. The new lines will be
output as well";

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[b][color=#ff0000]echo[/color][/b] "Escaping characters is \\"Like this\\".";


[b][color=#ff0000]echo[/color][/b] "
=============================
";


$foo = "foobar";
$bar = "barbaz";
[b][color=#ff0000]echo[/color][/b] "foo is $foo";//foo is foobar
[b][color=#ff0000]echo[/color][/b] "
";
[b][color=#ff0000]echo[/color][/b] "bar is $bar";//bar is barbaz

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[color=#008000]// You can also use arrays[/color]
$bar1 = array("value" => "foo");
[b][color=#ff0000]echo[/color][/b] "this is {$bar1['value']} !";
[color=#008000]// this is foo ;[/color]

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[color=#008000]// Using single quotes will
// print the variable name,
// not the value[/color]
[b][color=#ff0000]echo[/color][/b] 'foo is $foo'; // foo is $foo

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[color=#008000]// If you are not using any
// other characters, you can
// just echo variables[/color]

[b][color=#ff0000]echo[/color][/b] $foo; // foobar
[b][color=#ff0000]echo[/color][/b] "
";
[b][color=#ff0000]echo[/color][/b] $foo.$bar; // foobarbarbaz

[b][color=#ff0000]echo[/color][/b] "
=============================
";


[color=#008000]// Some people prefer passing
// multiple parameters
// over concatenation.[/color]
[color=#008000]
//with multiple parameters>[color=#ff0000]
echo[/color] 'This ','string ','was ','made.';
[b][color=#ff0000]echo[/color][/b] "
";
[color=#008000]//with concatenation[/color]
[b][color=#ff0000]echo[/color][/b] 'This '.'string '.'was '.'made.';

[b][color=#ff0000]echo[/color][/b] "
=============================
";


$foo = <<<[color=#ff0000]END[/color]
This uses the "here document" syntax to
output multiple lines with $variable
interpolation. Note that the here document
terminator must appear on a line with just
a semicolon. no extra white space![/color]
[color=#ff0000]END[/color];


[b][color=#ff0000]echo[/color][/b] $foo;


[b][color=#ff0000]echo[/color][/b] "
=============================
";


[color=#0000ff][b]?>[/b][/color]


[b]
[/b]
[/color]

ၿပီးရင္ browser တခု ကို ဖြင့္ၿပီး address bar မွာ
http://localhost/echo_example.php
လို႔ ရိုက္ ထည့္ၿပီး enter ကို ႏွိပ္ ပါက figure.1
မွာ အတိုင္း ျမင္ရ ပါ လိမ့္မယ္။

PHP lesson for self-study Tn_01f10

'code.1' ကို တလိုင္း ခ်င္း ေစ့ေစ့ စပ္စပ္
monitor screen ေပၚ မွာ ေတြ႔ ရတာနဲ႔ တိုက္ ဆိုင္ ေလ့လာ ပါ။.

PHP ကို ေလ့လာ ရာမွာ ကၽြန္ေတာ္ နည္းလမ္း တခု ကို ေဖၚျပ ပါမယ္။

အမွား အယြင္း မရွိ run လုပ္ႏိုင္တဲ့ PHP file တခုကို ရရွိတဲ့ အခါ ပထမ ဆံုး
တေနရာရာ မွာ copy တခုကို
ေနာင္ လိုအပ္ ရင္ ပြားယူ လို႔ ရေအာင္ save လုပ္ ထားပါ။ ၿပီရင္ PHP codes
ေတြကို ဖ်က္ၿပီး အမ်ိဳးမ်ိဳး run လုပ္ ၾကည့္ပါ။

အမွား ကို တမင္တကာ လုပ္ ၾကည့္ တဲ့အခါ ေနရာ ေပါင္းစံု မွာ
တၿပိဳင္နက္ လုပ္ရင္ အေျဖ ရွာရ ခက္
ပါတယ္။ တေနရာ မွာ အမွား လုပ္ၾကည့္ လိုက္၊ ဘာျဖစ္ လာသလဲ ေလ့လာ။ မွန္ ေအာင္ ျပန္လုပ္
လိုက္္၊
ဆိုတဲ့ နည္းလမ္း ကို သံုးရင္ မၾကာမွီ ကၽြမ္းက်င္ လာပါ လိမ့္ မယ္။

ဒီနည္း ဟာ အရင္ ကေရာ ယခု လက္ရွိပါ ကၽြန္ေတာ္ သံုး ေနတဲ့ self learning နည္းလမ္း
ျဖစ္ ပါတယ္။
(ကူးယူေဖာ္ျပျခင္းျဖစ္ပါသည္။)

http://www.myanmarhelper.co.cc

2PHP lesson for self-study Empty Re: PHP lesson for self-study 6th May 2011, 9:41 pm

စိုးစံေအာင္

စိုးစံေအာင္
MITR New User



နည္းမ်ိဳးစံုးနဲ႕ ေက်ာ္ခြၿပီး စမ္းပါတယ္ခင္ဗ်ာ။ Unable to connect တဲ့။

3PHP lesson for self-study Empty Re: PHP lesson for self-study 6th May 2011, 9:51 pm

Fox

Fox
MITR Reader



MITR Reader
local hosting မေထာင္ထားရင္ ေပၚမွာပါပဲခင္ဗ်...
အကို Wamp ျဖစ္ျဖစ္ Lamp ျဖစ္ျဖစ္ အရင္ဆံုး set up လုပ္ရပါမယ္...
internet ကေနသြားတာမဟုတ္ပါဘူး
ကိုယ့္စက္မွာ ကုိယ္တိုင္ေရးတဲ့ဟာကို ကုိယ့္ဟာကုိယ္ျပန္ၾကည့္ရတာပါ...

4PHP lesson for self-study Empty Re: PHP lesson for self-study 7th May 2011, 2:35 am

ⓃⓖⒶ ⓢⒶ ⓛⓊ

ⓃⓖⒶ ⓢⒶ ⓛⓊ
MITR Beginner



MITR Beginner
ဟုတ္ပါတယ္ ခင္ဗ်ာ .. wamp ေကာင္းပါတယ္ server ေထာင္ထားၿပီး offfline မွာလဲ ကိုယ့္ page ကို edit/preview လုပ္လုိ ့ရတယ္ .. hosting အခက္အခဲအားေၿဖရွင္းနည္း တစ္မ်ိဳးပါပဲေလ Smile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

 

Create a forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com