Short Note Of PHP — 1

Intro

XAMPP

PHP ကို ကိုယ့်စက်ထဲမှာ run ဖို့အတွက် xampp သွင်းထားဖို့လိုတယ်။ xampp သွင်းပြီးရင် C:\xampp\htdocs\ အောက်မှာ PHP file ကို သိမ်းရပါမယ်။ browser မှာ http://localhost/filename.php ဆိုပြီး ပြန်ခေါ်နိုင်ပါတယ်။

Chapter 1

PHP Basic
(PHP: Hypertext Preprocessor)

Syntax
C langauage , Perl Language နဲ့ တူပါတယ်။ အခုနောက်ပိုင်း OOP ပုံစံ အသုံးပြုလာပြီး အချို့ပိုင်းတွေမှာ Java syntax နဲ့လည်း ဆင်ပါတယ်။ PHP syntax ဟာ language တော်တော်များများ ကို remix လုပ်ထားပြီး ရိုးရှင်းလွယ်ကူပြီး နားလည်လွယ်ပါတယ်။

Source Files and PHP Tags

.php နဲ့ပဲ သိမ်းတယ်။

Standard Tags

<?php

…code

?>

Short Tags

<?

…code

?>

Script Tags

<script language=”php”>

…code

</script>

ASP Tags

<%

…code

%>

<?php echo $variable ?> အစား <?= $variable ?> ဆိုပြီး အစားထိုးရေးနိုင်ပါတယ်။

Anatomy of a PHP Script

ရေးရတဲ့ ပုံစံကတော့ C,Perl, Javascript တို့လိုပါပဲ။ အဆုံးမှာ semicolon (;) လေးနဲ့ ဆုံးပါတယ်။ variable တွေဆိုရင် $ လေးရှေ့မှာ ပါပါတယ်။

some_instruction();
$variable = ‘value’;

Comments

//Single Line Comment

#Single Line Comment

/*Multi-line

comment

*/

သိထားသင့်သည့်အချက်

  • <? php ဆိုပြီး space ခံပြီး ရေးလို့မရ
  • keywords တွေကြားမှာ space မခံရ (e.g : wh ile, fo r, func tion)
  • variable တွေမှာ space မခံရ။ function name တွေမှာ space မခံရ (e.g:$var name, $ varname, function foo bar() )

Code Block

code block ပုံစံနဲ့ ရေးသားရသည်။ braces ကြားတွင် code ရေးရသည်။

{

//some comments
f(); //a function call

}

Language Constructs

echo သည် output ထုတ်ရန်အတွက်ဖြစ်သည်။ print လည်း အသုံးပြုနိုင်သည်။

echo 10; // will output 10
print (10);

DataType

PHP က datatype အများကြီးကို support လုပ်ပေးပါတယ်။

boolean : true or false value သာ

int : နံပတ်များ

float : ဒဿမ များ

string : စာကြောင်းများ


2 thoughts on “Short Note Of PHP — 1

  1. Here’s another tings you should know about PHP…

    1. You can you ‘Variable with space’ in PHP like this ${“var name”}…
    2. Function names are case in-sensitive while Variables are case-sensitive
    3. No need of braces, this is totally legal (and I love it :)
    if(condition):
    #do something
    endif

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>