2. 3. Syntax 4. (Variables) 5. s (String) 6. a (Operators) 7. n sn 8. (Loop) 9. While 10. For 11. a (Array) 12. (Function) 13. PHP 14. $_GET ! 15. $_POST !
B.a n ei • • • • • • • • • •
1.a n ei u | ( Advanced PHP Tut or i al i n Bangl a) 2.ei 0 1234 u ( PHP Dat e Funct i on Tut or i al i n Bangl a) 3.ei i4k9 1234 u ( PHP I ncl ude Funct i on Tut or i al i n Bangl a) equi 4.ei 1234 ( PHP r eq ui r e Funct i on Tut or i al i n Bangl a) 5.ei 1i 1234 u ( PHP Fi l e Funct i on Tut or i al i n Bangl a) 6.ei 1i ? u ( PHP Fi l e Upl oad Tut or i al i n Bangl a) 7.ei k u ( PHP Cooki e Tut or i al i n Bangl a) 8.ei 0 34 u u ( PHP Sessi on Tut or i al i n Bangl a) 9.ei e hK u ( PHP Er r or Handl er Tut or i al i n Bangl a) 10. ei 0i 1234 ( PHP Mai l Funct i on Tut or i al i n Bangl a) 11. 11.ei 1l u ( PHP Fi l t er Tut or i al i n Bangl a) C.ei 0Po R
• • • •
1.ei 0Po R u | ( PHP Fr amewor k Tut or i al i n Bangl a) 2.a яk aK 0pg2 e 2 ei ( OOP & PHP Tut or i al i n Bangl a) [ \ a яk aK ei ( OOPHP Tut or i al i n Bangl a) \: \:^- ` || \: \:6- 10 || \: \: 1111 - 15 | | \: \: 1616- 23
•
4.0 ia4i u4 e 2 i4s ( CodeI gni t er Bangl a)
•
5. u KT sT u ( MVC St r uct ur e Tut or i al i n Bangl a)
•
6.0 ia4i 41a ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)
•
7.0 ia4i 0 ia4i e pg ep 34 ijk ( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )
Downl oad
& I nst al l
Tut or i al
in
A.ei
1.
ei 0 u | ( PHP Basi c)
:
яo$ %
ei' e %( i! skp m e я : % skp ,c p g % b।e ,c 2 instruction e 3 run s$k$ 2 я ,$।“ i!” i! 6 7 ,c ei skp ( iuя mu
$nt :
handle ।3
u ei' o$ я я 6 o$ ei' !( 2 Process 3: 3 : : (Picture,Content etc) : % 3 : (math calculation,file operation etc)6 e
; HTML e n iuя o$ b uя > ।
ei' (PHP) ?: PHP Hypertext Preprocessor e i!,k p ,HTML-embedded skp ($я।ei' e
( syntax ( C,Perl,Java
@ ।ei ($яA ud , o$ я d6 D6E ! i । ei' (PHP) %( я : : : 1.HTML .; HTML Form. 2. C я 6 , @ %2। 3.я skp 1o pя4 ?:
3 o$ ei' hosting(я $( ) 6 ,।e я (6 ,।e ;$A $ s 6
% ' ,। % 66 я % я mu i o$ is ।e я m k o$ ( is 6 , % mu * o$ 1.e PHP -compitable o$ 3: apache 2.PHP *k in k in o$ 1.o$ b uя 3 я $ k(e 6 is :$ i %2) 2.e k e! 3: !।% ei' e я Specialized e!o , 6 । s 6 %2। webcoachbd.com e Au $ ( N % $ ei' 6 । ।
2.
ei i4s34 ( PHP I nst al l at i on Tut or i al i n Bangl a)
:
яo$ %
p Au $ A 6 N2 6 , e 76 % , ।k in o$ (6 %2i e @ is :6 , o$ 3 apache e ai ei' % e ! o$ o is :$ 3:MySQL, я ( 6 2।e o$ ( O o$ 3 $।P$ e6k (( ' :$ o$ ( я 2।e ,я R :c e e e o$ 3 is : ( e i is ,$ 3 ।% % : % : is :6 , ।o$ A ,c XAMPP.XAMPP e
! u ! is http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe a o$ e 6 is :। in ; !s XAMPP e eA %i : ! k o a a 6 - 3 U i is :$2 (i e XAMPP Control Panel %i :6 a n % 3: C U i is : 6 , C:\Program Files\xampp C:\xampp ei । e @ start click (Apache e MySql)।
Apache o MySql ' b uя eU http://localhost ' 6 e я । % English k ।
ei яA % 7 % 6 is mn ,$2 a n % mu A e , я 2( )
3.
ei 0 0 g o 4 ( PHP Code Wr i t t i ng)
:
яo %
qr C drive e XAMPP i4s r g 4 jt ei 01l htdocs 4 ? 01l ?v 0 o4 ?4 web content g o 4। www !kn ! ik ,c “C:\xampp\htdocs”(6 3: a U i is : 3:D drive 6 e , “D:\xampp\htdocs”). e 3: ei ! ik6 “mytest.php” i 6 , % e 6 a 6 e -b uя eU http://localhost/mytest.php %c e ! ',6 %( e ! ? !?6 6 ei' ! я 2 s iя! o %2 3: Net Beans, Dreamweaver i6 : e( 6 ! a @ ।e( % 6 @i , 3 @ ( ! ।e( IDE (Integrated Development Environment).% 3 6 cn @ , ।
4.
ei 0 2 j u ( PHP Synt ax Tut or i al i n Bangl a)
:
яo$ %
ei' ! я 6 ai i extension .php 6 ,।3: .html 6 , ei' ! execute , । * ei' ! e p6A a 'h :$ ; ,। * e ei' Scripting Block( e 6 3 ,$ $ e b ) !kn 6 6 । *p6A % : instruction(code line) k d ; ,। o e % ! e! ( !/U$ % 3 , ) e ' 6
e яA mypage.php , $ htdocs browse :$ : save in e я $( $।e b uя eU http://localhost/mypage.php e en : ' 6 %u :6 ।
ei' e %u я :A sn ^6 ,$ echo o print. ei' n:$ 'h %2 3: ei' ! e( :$ 6 , e !( % execute , ।6 n
!( e! , a m $ 3: 6 , e n : 76 % 6 '$2।e i n 6 ' i // # % , i n 6 ' i ! %( /* e ; */ 'h , 6 ,। : a p A , 3 k 2 ki।3 ! 6 echo "Hello World! echo "Hello World! echo "Hello World! echo "Hello World! echo "Hello World!
"; "; "; "; ";
e 6 k।
% : ei' ! 6 s я ,e p A 6 6 я :6 ।
5.
ei 0 u ( PHP Var i abl es Tut or i al i n Bangl a)
:
яo$ %
,c e t 6(Container) 3 % a 6 6 ।3 e kk String “Hello Bangladesh” a e integer value 100. e e e 6 ( e 2 e declare a ; ) !я , 6 , 6 (value)A
6।ei' 6 “$” ei 'hA :$ ai 6 , , я । * case sensitive. 3 $a_number and $A_number :A % : , ei' e :bc6। *m k ei' 6 ,$ $variable_name = Value; u % '6 ( 6 3: 6 6 ' i 6 ,1.
*ei' e “Loosely Typed” ($я 6 i declare $ e i(@) ul o ei' я
R ! i n ।
d6: 1.ai letter or “_”(under score) :$ 6 ,। 2. @ alpha-numeric characters o underscores. a-z, A-Z, 0-9, or _ . 6 । 3. s 3 ।3: e a@ ,$ 6 , “___”underscore ($my_string) a N , 6 ak($myString)6 ,।
6.
ei sT2 u ( PHP St r i ng Tut or i al i n Bangl a)
:
яo$ %
ei' s e6k , o (E % ' ,$।ei' Career e ei s e (tg g ।6 i e h @ %।
s , %( e D6E 6 ,।e s e , ,6 a e $ store
6 ।' : ei s : D6E 2,e $ store ,$2 % echo ,$2। 1.
u u: , p s $my_string $ i $ :$ ,$2 % d6E$ % s echo ,$2, $ store i।e я $ 6 , 3 3i s % e @ , p @ 6i e $ i $ store । %c e u ! k ।b uя ' 6 %u ।
e6k6 Double quotes d s D6E ,$2 e Single quotes d s D6E 6 e i R,6 , %6 o apostrophes '6। 1.
3: s e 6 single quotes , : ,$ 6 , e echo ‘PHP it\’s neat’ % e % 66 double quotes , e6 2 @ %2 3 single quotes e i। ei' 3 d6:A % ' , e :A @ 6 p g ($я e kt ^6 ,$,n ei' 6 e o$ %2 3 :$ , i s 3 $ quotation , 2 N i। , heredoc,e 66 s ! 6 , , 7 ,।' : e 6 ,$1.
e 3: s 6 , $A я ai $ 6 ,*<<< 2 identifier %2 3 % , 6 , heredoc %( 3 % TEST , 2। * ;o eA , 2 e k :$ ; ,। *e яi e i ,,(indent) iA 3 । %u ' 6 % 3,6 % ( i b :$ я ^6 ,$) ( s e 6 , ।
7.
ei a u( u( PHP Oper at or s)
:
яo$ %
a - $ manipulate 6 ^6 ,$।3 @ a %2 1.Unary – e $(operand) $ я । 2.Binary-:A $ $। 3.Ternary- 3A $ $ । e % Operator ( a kEd 6 3-Arithmetic, Assignment, Comparison Operator etc. a i4K a a ( ASSI GNMENT OPERATOR) OPERATOR) e a ( e $ a e $ 6 ^6 ,$। $my_var = 4; $another_var = $my_var; e $my_var o $another_var u$i , 4. Operator
j949 a ( COMPARI SON OPERATOR) OPERATOR) ei Operator $ e @ relationship ' ।ei Operator n statement e 6 % $ statement true false. e , ^6 2 Comparison Operator :$ ,$x=4 o $y=5 @ Operator
English
Example
Result
==
Equal to
$x=$y
False
!=
Not equal to
$x!=$y
True
<
Less than
$x<$y
True
>
Greater than
$x>$y
False
<=
Less than equal to
$x<=$y
True
>=
Greater than equal to
$x>=$y
False
sT2 a ( STRI NG OPERATOR) e 6 %(i % :2 % , o 2-“”, ‘’ ARI THMETI C e 2 ASSI GNMENT OPERATOR e COMBI NATI ON Programming e e '6 я ,c e $ :c , N , 3 ( kt।% 3: 1 N 6 ' i 6 , $counter=$counter+1; 3 , k e $counter+=1; Pre/Post-Increment e Pre/Post-Decrement: u e ad 6 ,6 ,e % ! %2 $
1 N $x++ 3 $x += 1; a $x = $x + 1 e । % kt @ “-” a ^6 ,।
8.
ei K34 0sK ( PHP Condi t i onal St at ement )
:
яo$ %
6 u action $ я n sn ^6 ,$।@ % % o$ i e e feature 3 ( 6 ' i 3 6 3: u % i : 12 %( i 6 , : “Good Morning” % 3: u 5 i 6 , : “Good evening” ei @ e '$o я : o a ! n! я( 6 Conditional statement e : ,condition e u t ei' s$k$ я( 6i । ei' 6 $ @ Conditional statement %2*if statement *if…else statement *if…elseif…else statement *Switch statement * I F STATEMENT
if statement A :$ 2 ! execute ,$ 3 % : :$ condition A true ,$।' u: , %u , Have a nice day 3: p : Saturday ,$ 3: ! । 1.
* I F…ELSE F ELSE STATEMENT %c o 6 e 2 3: k 6 , , , 3: k , i।e i if…else statement e u: ,।e( 6 a $ % si , e @ e ei' ! :$ । 1.
: condition 3 :$2 3: true ,$ a n ! 3: : 3: Saturday ,$ 6 , %u , Have a nice day % 6 , Today is not Saturday. * I F…ELSEI F ELSEI F…ELSE F ELSE STATEMENT ei statement d e e @ ! b execute 3 $। view source print? 01. 02. 03.=60) 05.echo "First Division"; 06.elseif ($number>=45 and $number<60) 07.echo “Second Division”; 08.elseif($number>=33 and $number<45) 09.echo "Third Division"; 10.else 11.echo “Failed”; 12.?> 13. 14.
9.
ei 9 u ( PHP Loop Tut or i al i n Bangl a)
:
яo$ %
% e я 6 % : i ( 3 ei 50 i e @ @ ei 100
я @ i6 :।p g e я ,c e 'n i ei g bt я $ i i 3 $। :$ e( 3 $। ,c e e statement 3 :$ e ! b :c $ execute 3 $ 36k % : я ; ,$। 4 @ %2While Loop Do…while Loop For Loop Foreach Loop
10.
ei While 9
:
яo$ %
3 e condition true ,$ 6 while A e ! b execute । 2 j 1.while (condition) 2.{ 3.code to be executed; 4.}
3: condition false ,$ 6 b 6 !A eN$ 3 $।3 ; b A % 6 condition % ' ,true , ! % execute ।condition e 36 :$ %2 66 e 'i।3: 01. 02. 03."; 08.$i++; 09.} 10.?> 11. 12.
p i=1. e while($i<=5) a n A 66k ' 36k I e 5
2 ,।% A p6 1
N। !A %u % eThe number is 1 The number is 2 The number is 3 The number is 4 The number is 5 e I e 6 : %u %?2 i % 6 eA while loop e 6 i ! execute , । DO…W DO WHI LE LOOP e while loop e 6i @ e k 3 condition A ; test ,$, 6 6, 3 ,$ while e।a n k e A execute ,i। 2 j 1.Do 2.{ 3.Code to be executed 4.} 5.While(condition);
3 ' u: ,A !Ao u 6 ei %u : @ я n । 01."; 07.} 08.while ($i<=5); 09.?>
n e 3: i=6 :i 6 , ,?' 6 This is line 6 This line is outside while loop.so it will not repeat.
: A p ' 2 N i e ! execute ,$2।p execution e ' 2 3 A repeat , ?n while loop e p i ei ' ,$।
11.
ei 1 9 u( u( PHP For Loop)
:
яo$ %
ei A e яA। e я while :$o ,$,6 2 @ eA ^6 ,$। 2 j 1.for (init; condition; increment) 2.{ 3.code to be executed; 4.}
for loop statement b 6 3A expression $ 3( k d k ,$।1 A assignment statement(loop control variable),p A g bt %(i e e execution ,$।2$ A Boolean expression 3 p6 g bt %(i e e s6(evaluate),$,ei true , g bt ' % false return 6 , g bt n ,$ 3 ।3$ A :$ loop control variable e N 6 6 ^6 ,$।' u: ,A : A ,$2 i=1 :$ e eA ' 36k I e 5 e '$ 2 ,$।% I e 1 N। 1."; 5.} 6.?>
Output The number is 1 The number is 2 The number is 3 The number is 4 The number is 5
3 expression eA6 e @ expression 6 , 3( d k ,।3: Boolean expression 6 , e default true ,$।ei u: , ( %u 1-10 ,। % %2 foreach loop eA array e ^6 ,$ 6 i %2
12.
ei a u ( PHP Ar r ay Tut or i al i n Bangl a)
:
яo %
e e single value e t(container).n a e @ value’ container t।e a , 2 u : (R6 3 p6A u : :c value %2-key index 3 : u : A ,। @ % 2 2 , s %2 e 3: e( single variable e store 6 ' 6 , e ,$city1= “Dhaka” $city2= “Chittagong”
$city3= “Rajshahi” $city4= “Sylet” $city5= “Khulna” $city6= “Barishal” n e a e( e e @ 6 ।a @ (> d6 ,c 2 u : k(series of element) 3 u : ( index 0
, k u6 । a 3 ' ,яA ,c1.
e variable e , store , (2,p6A , e eA u : e p6A u : eA index :c , (2।array’ 1 u : e index/key ,c 0 6 , e Dhaka[0],Chittagong[1]… e ( ।e % 3 u : e index number ul u : A 6 ।3 1.
6 3: % ' i 6 , a ei !l 6 :6 ,=> ei a A :।@ % ' c ei u a A starting index 2 : , 6 , e 6 ,। 1.“Dhaka”, “Chittagong”, “Rajshahi”, “Sylet”, “Khulna”, “Barishal”, “Barishal”); 3.?>
ei a 3 u : g ^6 ,6 6 index :c я। a a ( ASSOCI ATI VE ARRAY) e6k6 g index/key : % ' i string o , 6 ।e i associative array ।3: 1.32, "rezwan"=>30,"refat"=>34); 3.?>
li434 a ( MULTI DI MENSI ONAL ARRAY) ARRAY) e e a 6 p6A u : eA a ,6 % ei a p6A u : o eA a ,6 e e %o। 1.array("Bangladesh","India","Pakistan"), 4."Europe"=>array("England","France")"Africa"=>array("Kenya", 5."Libya","Somalia")); 6. 7.?>
a r 92
FOREACH LOOP @ eA associative array %2 e % g bt 6 ' foreach statement : e 6 ।3: 1.”; 6.} 7.?>
e ,c e 3 % !b :6 e i @ ! p !b ic6 execution 6 ।e ei' e g k 6 ।p 700 eo l i %2 ei' 6। e 3 , 6i e execute , % я 3 я (
e 3 । 2 j 1.function functionName() 2.{ 3.code to be executed; 4.}
A: : e : 3 :i 3 7 3 A । ak _ : ,6 , m : , । e simple 3 : % 01.
02.function writeName() 03.{ 04.echo "Md.Rejoanul Alam"; 05.} 06. 07.echo "My name is "; 08.writeName(); 09.?>
Output My name is Md.Rejoanul Alam 1234 0qa 0qa 3 ( %o A u 3 ,e e: PHP variable e 6i। e b 6 ,।3 01."; 05.} 06. 07.echo "My name is "; 08.writeName("Rejoanul "); 09.echo "My Father's name is "; 10.writeName("Samad"); 11.echo "My brother's name is "; 12.writeName("Anjirul"); 13.?>
Output My name is My Father's name My brother's name is Anjirul Alam. % u: ,
6 6 ^6 ,$।ei 6 ei' я :$ 3 $ e ei' :$i e ,$।ei' 6 :A $ %2 3 ,6 ! (iuя i) 6 %6 ^6 ,$$_GET e $_POST.e ei'Aee : , 3 :A i l % eA %2। 1.
iuя 3 A g k 6 ! ei' i ' 3 3 “welcome.php” e % я P$ k 2 3 !A6 method=POST :$ %2,Form e ! ei' 6 6 :A d6
, ,$ POST e GET. welcome.php iA , e 1.Welcome ! 2.You are years old.
e @ % A6 я $( $ : rezwan e age : 24,e k %u e Welcome rezwan! You are 24 years old.
15.
ei $_GET $_GET 0g ( PHP $_GET Met hod)
:
яo$ %
6 GET ! e > 6 b uя eU p:6 ,$ e i :6 $।6 2 N 6 k 6 > 3 6 eA E %2 @ 6 c 250 A character (e % e b uя u 3 6 : URL e D:a 6: ,।) 3 1.
3 iuя k 6 b uя eU ' 6 : http://www.w3schools.com/welcome.php?fname=Peter&age=37 welcome.php iA e $_GET Method , ! g, । 1.Welcome . 2.You are years old!
16.
ei 0s 0g u ( PHP $_POST Met hod)
:
яo$ %
ei d66 3 6 i > , 6 u :6 b uя eU o p:6 ,$ । e @ , 36 ic 6 > 6 (% c 8Mb 3n > 3 $।)
e 3 iuя k 6 b uя eU ' 6 : http://www.w3schools.com/welcome.php % e ! $_POST Method d66 (b,E6 ,। Welcome ! You are years old.
o4 0 4 t 4 al 6 , GET Method % 6 e iuя password i6 : kt POST Method , ।
B.a n ei 1.
a n ei u | ( Advanced PHP Tut or i al i n Bangl a)
:
яo %
webcoachbd.com e ei ei' a ! n! Au 3-ei' ,k, i, !,e ,n i6 :।
2.
ei 0 1234 u ( PHP Dat e Funct i on Tut or i al i n Bangl a)
:
яo %
ei 0 1234 ( PHP DATE FUNCTI ON) % % oя | 6 6 / : 6 ' i6 6 ei' e date() d eA 6 ।3 view source print? 1."; 3.echo date("Y.m.d") . " "; 4.echo date("Y-m-d") 5.?>
Output 2009/05/11 2009.05.11 2009-05-11
e % 3 A 2n A : :।
3.
ei i4k9 1234 u ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)
:
яo$ %
% ic i eku %(i ei' e e i a a % ei' i i $ :6 include() :$। Require()- , fatal error((6 ) : e skpA eku n :। Include()- , 6 : e skpA eku e :A :$ a я ' 3 $ 3 % 3: e , ,! , 3 a 3 % ' 3 % o$ i яi e : 6 , e ei' i ( , ,! , i6 :) D6E a я e :A :$ 3 ( :6 । % : % : p6A я % e( 3 ( 6 , ।% 3: ei include i 2 %! e 6 я 3 ( 6 , я ($i 3k ,।b я ($ % 3 ( 6 , ।u: ,,@ “menu.php” e i aa2 ' 6 1.
href="/default.php">Home href="/tutorials.php">Tutorials href="/references.php">References href="/examples.php">Examples href="/about.php">About Us href="/contact.php">Contact Us
e 3 ( 6 , e view source print? 01. 02. 03.
04. 05.
06.
Welcome to my home page.
07.
Some text.
08. 09.
4.
ei 1234 ( PHP r equi r e Funct i on Tut or i al i n Bangl a)
:
яo$ %
require() include() e 6i @ t , %' e u t e n6 %2।
Include() e e я :। 01. 02. 03. 04. 08. 09.
Error message: Warning: include(wrongFile.php) failed to No such file or directory Warning: include() Failed opening (include_path='.;C:\php5\pear') in C:\home\website\test.php
in
[function.include stream on line
open C:\home\website\test.php
'wrongFile.php'
[function.include inclusio
for on
line
Hello World! Notice that the echo statement is executed! This is because a Warning does not stop the script execution. require() Function e e я : Now, let's run the same example with the require() function. 1. 2. 3. 7. 8.
Error message: Warning: require(wrongFile.php) failed to No such file or directory Fatal Failed opening (include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5 echo statement e eku ,$ i
in
open C:\home\website\test.php
error: require() required
[function.require stream on line
[function.require 'wrongFile.php
5.
ei 1i 1234 u ( PHP Fi l e Funct i on Tut or i al i n Bangl a)
:
яo %
fopen e : ei' 6 i 3 ।3 1. 2. 3. 6. 7.
fopen e b :A я %2 eA “welcome.txt”a n ei iA e d6EA “r” e e 3 : R : 3 iA as ( !)g।e “r” : %2 6 i eA read only ! । e % 2 Modes
Description
r
Read only. Starts at the beginning of the file
r+
Read/Write. Starts at the beginning of the file
w
Write only. Opens and clears the contents of file; or creates a new file if it doesn exist
w+
Read/Write. Opens and clears the contents of file; or creates a new file if exist
a
Append. Opens and writes to the end of the file or creates a new file if it doesn't exis
a+
Read/Append. Preserves file content by writing to the end of the file
x
Write only. Creates a new file. Returns FALSE and an error if file already exists
x+
Read/Write. Creates a new file. Returns FALSE and an error if file already exists
3: :c iA fopen() function A 6 , 6 , ' 6 !A e я : , 1. 2. 3. 6. 7.
e 1i 0kя
fclose() function : i n 3 । 1.
ENDEND- OFOF- FILE 0 e : i ; ~2 6 ' ,। if (feof($file)) echo "End of file"; e e я (। e 1i LINE BY LINE fgets() function A : ei' 6 eA eA i u 3 ।ei A i :A i ' 3 ।' u: , : eA eA eA i u ; ~2 3n। 01."; 07.} 08.fclose($file); 09.?>
CHARACTER BY CHARACTER CHARACTER e 1i fgetc() function A e i
e e ak u। ' u: ,A i
eA eA ak u। view source print? 1.
6.
ei 1i ? u ( PHP Fi l e Upl oad Tut or i al i n Bangl a)
:
яo %
ei @ iuя % i % ! 6 ।3 01. 02. 03. 04. 11. 12.
e action="upload_file.php" e method="post" : ,2 a n k ! (
eя iuя k 6 e ^6 ,।e ,c e 2 i 3 iuя 6 ( :(e :/я )।ধরুন % % i , i ' 2 e ak % i ' я i i 6 ' i 6
: 3 % % iuя i 6 ,c ,i , я
i % iuя e я ( : c,e i i k i 3 % ei 6 (iuя o ! i6 :)k6 2। k ijk j t setcookie() function e ^6 , k D6E 6। setcookie() function A ai ( e %( 6 ,। setcookie(name, value, expiration); namename:e k , ei A , 6 , kA n 6 । value:e k6 k ,, ^6 k ,c username(string)e last visit(date) expiration:e oi 3 kA : ; ,।3: % ei : 6 A(kA 6k )R : 6 , b uя s i kA 2 3 । ' u: , % eA k D6E 3 iuя ; o iA visit 2 i 6 k 3 6 e : 6 eя iuя 6 aa % i %।% ' i k : R :6
3 % e : 30 : :2।a n e oi s iuя ignore ,2 3 30 : 6 e i i । 1.
3.setcookie("user", "rezwan",$expire); 4.?> 5. 6......
k ud (RETRIEVE) RETRIEVE) 3: k : ; , 6 , ei' $_COOKIE variable : k retrieve 3 । 1.
ei ! isset , ,2 e P6 6 3 "lastVisit" k eo iuя 6 %2 ,3: 6 , iuя ; visit 2 6 : 3 । k 9v 01 k 2 %( e P6 , 3 k : ; ,2 । view source print? 1.
8.
ei 0 34 u ( PHP Sessi on Tut or i al i n Bangl a)
:
яo %
3 ep я , ,n 6 n e e 6।mu 7 % ।% я 2, ; 2 e 6 6 2 ।n in e ,-o 76 % % e6k ।ei' ei @ :2।ei' iuя 6 k , я।ei 6 as E e iuя i 6 ( 6 2 3 ।3: s E 6 ' 6 , ! 6 ।ei' p6A iuя я a ' unique id (UID) D6E । ei' iuя 6 k %( 6 ,।ei' session_start() : 6 , e tag e %( 6 ,। 1. 2. 3. 4.
5. 6. 7.
ei !A , 3 iuя яs e ei e %i! : 6 6 । 0 34 2k4 2k4
6 k o ud R u , $_SESSION , । 01. 06. 07. 08. 09. 13. 14. 15.
%u Pageviews=1 ' u: ,A page view counter(page 6 : ,2 6 : я) D6E я।eA я isset() A , ,।ei A ' : ‘views’ %(
i %2 ।3: ‘views’ variable 6 , % a : counter u 6 ।% 3: 6 , ‘views’variable D6E e e 1 :। 01.
e 0 34 2 ( DESTROYI NG A SESSI ON) ON)
! 2 6 unset() or the session_destroy() function , ,।] unset() function :c e 2 6 ^6 ,। 1.
e mg 6 session_destroy() function ^6 ,। 1.
session_destroy() reset e e6 6 , ।
9.
ei e hK u ( PHP Er r or Handl er Tut or i al i n Bangl a)
:
яo %
3 ei' skp o ep D6E 6 error handling eeA (tg ।3: e ( ) ' ! a 6 6 , % p g A % , e t я6 7 । ei Au e ' e 2 p'6 d6 % ' ,।3 "die()" statements Custom errors and error triggers Error reporting "DIE()" DIE()" 0sK t e hK e e 2 ! 3 kk i । 1.
3: iA as6i 6 , b uя ' 6 p: । Warning: fopen(welcome.txt) [function.fopen]: failed No such file or directory in C:\webfolder\test.php on line 2 iuя u 6 я
k : я 6 @( я :6 ।3 01.
e 3: iA 6 , ei я : । File not found
to
open
stream:
ei !A u ! ' e n।e e @ d6 e6 error , skp n , 3 ।6 e d6 , a R ।
s e hK hK ijk e % @ e ei' D6E 3 e , 3 call 3 ।ei k :A(error level and error message) e c 'A (optionally: file, line-number, and the error context) । error_function(error_level,error_message,error_file,error_line,error_context) Parameter error_level
Description %।iuя b 6 error report level :c ।ai e
value number 6 ,।' m error report level : ,। error_message
%। iuя b 6 я error message :c ।
error_file
pc। p iA ul 3 ,2।
error_line
pc। p iA ul 3 ,2।
error_context
pc।e a ul(Specifies an array) 3 e 6 : ।
e R2 e 4( 4( VALUE) Value Constant 2 E_WARNING 8 256
E_NOTICE E_USER_ERROR
Description run-time errors. skp Execution n , Run-time notices. iuя b 6 t ।e E_ERROR e 6 3 p g : PHP
function trigger_error() , । 512 E_USER_WARNING Runtime warnings generated by a call totrigger_error( ) 1024 E_USER_NOTICE Runtime warnings generated by a call totrigger_error( ) 4096 E_RECOVERABLE_ERROR Catchable fatal error. 8191 E_ALL errors e warnings, @ level E_STRICT 2 u (E_STRICT PHP 6.0 e E_ALL e a ,।) e e 1234 ijk e hK e яn 1.function customError($errno, $errstr) 2.{ 3.echo "Error: [$errno] $errstr ";
4.echo "Ending Script"; 5.die(); 6.}
e e @ error handling ।3 e ' 6 e e error level e я ।ei e я %u , : skp p । e hK 0
ei'6 !l , e error handler li ।% ic e 6 я 6 error handler :6 PHP 6।' u: , : ei я D6E error handler , 6 , set_error_handler("customError");
3,6 error handle я % я D6E , 6 ' i,6 i set_error_handler() e e : ,2 % 3 ( 36 error level e я। e e u: , 01.Error: [$errno] $errstr"; 06.} 07. 08.//set error handler 09.set_error_handler("customError"); 10. 11.//trigger error 12.echo($test); 13.?>
u ! %u , e Error: [8] Undefined variable: test 0 4 9 TRIGGER
skp 3 iuя ! i 6 trigger u E 3 iuя /a@ i ।trigger_error() function : e ,।ei u: , test 3: 1 e ' u , 6 error ,। 1.1) 4.{ 5.trigger_error("Value must be 1 or below"); 6.} 7.?>
%u Notice: Value must be 1 or below in C:\webfolder\test.php on line 6 e error skp 3 я ( trigger 3 e % 3 ( :c :6 3 error
level A trigger ,2। m error e @ • • •
E_USER_ERROR E_USER_WARNING E_USER_NOTICE
u: , 3: test e 1 e ' , 6 , e E_USER_WARNING error A , e e % я D6E error handler A , । 01.Error: [$errno] $errstr "; 06.echo "Ending Script"; 07.die(); 08.} 09. 10.//set error handler 11.set_error_handler("customError",E_USER_WARNING); 12. 13.//trigger error 14.$test=2; 15.if ($test>1) 16.{ 17.trigger_error("Value must be 1 or below",E_USER_WARNING); 18.} 19.?>
%u Error: [512] Ending Script
Value
must
be
1
or
below
e a2 PHP 6 error_log() e li %2 e : 3 ic error log( 3 A , 6 6 )A > 6 e я i R 6o। ii tq e 0 я 4
handler customError($errno, "Error: "Webmaster
//set error set_error_handler("customError",E_USER_WARNING); //trigger $test=2; if { trigger_error("Value must } ?> %u Error: [512] Value Webmaster has been notified ei ! e e i
handler
error ($test>1) be
1
must
or
be
below",E_USER_WARNING);
1
or
below
Error: [512] Value must be 1 or below
10.
ei 1l u ( PHP Fi l t er Tut or i al i n Bangl a)
:
яo %
3 ! a : un 3 iuя i
% ei' l 6 : g,3 ((validate/acceptable) e 2 6(filter) ^6 ,। o ep e i (tg। ( o ep i i u ।% 3 o ep D6E 6 i 3
i ! % filter i d я ,। e t я6 ;।! n un
%6 3• • • • •
e ib 6 ! k o !
!
1234 e 2 1l
filter 6 ' ( , ,•
filter_var() – :c e l : e filter ।
•
filter_var_array() – ei n l : e @ l ।
•
filter_input – e i e l
•
filter_input_array – e @ i e ei n l : l ।
•
' u: , filter_var() function : e g validate
01.
ei !A "FILTER_VALIDATE_INT" d $int l ,e %u "Integer is valid" 123 e integer. VALIDATING e 2 SANI TI ZI NG l 2 @ VALI DATI NG FI LTERS: •
user input validate 6 ^6 ,
•
: , ( 3 URL E-Mail validating)
SANI TI ZI NG FI LTERS: •
e s e :c ak a : я , ,।
•
s return ।
OPTIONS e 2 FLAGS Option e Flag :c l a6k filtering option 3 ( 6 ^6 ,।n l n option e flag %2।' u: , eA g validate 6 filter_var() l e "min_range" o "max_range" option , ,2। 01.array 06.( 07."min_range"=>0,
08."max_range"=>256 09.) 10.); 11. 12.if(!filter_var($var, FILTER_VALIDATE_INT,$int_options)) 13.{ 14.echo("Integer is not valid"); 15.} 16.else 17.{ 18.echo("Integer is valid"); 19.} 20.?>
u ! 6 options ai associative array 6 6 , e “options’’ 6 ,।3: flag , , 6 , e a ,o я ।e 3,6 300 g n :c E @ 6 i e %u , "Integer is not valid". VALI DATE I NPUT p P6 ,6 , 3 ib 6 ! 3 % я2 6 ast %2 ।6 filter_input() function d ib 6 ! l 6 ,।u: , 01.
:u u: , e i(ii) %2 3 "GET" method , > ,2। 1. ' i e "email" 3 GET ! , > ,2 ast %2 । 2.3: i e ast 6 , ' e R ii eU । SANI TI ZE I NPUT p P6 ,6 , 3 ib 6 ! 3 % я2 6 ast %2 ।6 filter_input() function d ib 6 ! sanitize 6 ,।u: , 01.
03.{ 04.echo("Input type does not exist"); 05.} 06.else 07.{ 08.$url = filter_input(INPUT_POST, 09."url", FILTER_SANITIZE_URL); 10.} 11.?>
:u u: , e i(url) %2 3 "POST" method , > ,2। 1. ' i e "url" 3 POST ! , > ,2 ast %2 । 2.3: i e ast 6 , sanitize(ap яE ak : ) e e $url variable e k । 3: i e@ s , "http://www.W3ååSchøøools.com/" 6 , $url variable sanitizing e e ,। http://www.W3Schools.com/ e \ i49 1l e @ 6 e @ i l ।e e call e( filter ' % filter_var_array the filter_input_array function , 6 ।3 view source print? 01. array 05.( 06."filter"=>FILTER_SANITIZE_STRING 07.), 08."age" => array 09.( 10."filter"=>FILTER_VALIDATE_INT, 11."options"=>array 12.( 13."min_range"=>1, 14."max_range"=>120 15.) 16.), 17."email"=> FILTER_VALIDATE_EMAIL, 18.); 19. 20.$result = filter_input_array(INPUT_GET,$filters); 21. 22.if (!$result["age"]) 23.{ 24.echo("Age must be a number between 1 and 120. ");
25.} 26.elseif(!$result["email"]) 27.{ 28.echo("E-Mail is not valid. "); 29.} 30.else 31.{ 32.echo("User input is valid"); 33.} 34.?>
11.
ei 0i 1234 ( PHP Mai l Funct i on Tut or i al i n Bangl a)
: яo %
% PHP mail() d o я
ii > 6 । 6 1.mail(to,subject,message,headers,parameters)
to
я। e 3 ii R i R i 3 ।
subject
я। e ; ul ।
message
я। e я 3 > ,। я i( (\n) 'h d b , e i 70 ak
headers
pc। e d a6k 3 ( 3 । 3:From,Cc,Bcc.
parameters
pc। a6k 3 ( 3 ।
: i 3 я % s ii is 6 , e php.ini iA i a3 E ( 6 ,>>76 ,c?b6 ,o : i-% 2 i 6 , । % 3 , s p i! 2 % : i( , s i 6 : e i ।e k % @ ' k u। @ % e Au i %2 e p6A Au n s %2 % % ' c 3 n( % i R ' % 3 6 76 % Au A 6я 2 (2।a n ! ।e я ei' i ।' u: , eA k я > ,2 p i 3 2 (a n [email protected] ei i) PHP MAI L FORM
Email: Subject: Message:
"; } ?> o : o : p : 3 ii e aA 2 3: 6 , HTML Ai : o 3: 6 ,
! i R : o ei 3A logic e ^6 ,2। e 3 k 6 яA reload , e 3 : ii e aA 2 6 i R :। : :e 4r dj 4 ej ei 1R t a \ iuя 0i rj e ii i4я 34।ii i4я 34 0g u t form validation. validation.q PHP 1l (Filter) Filter) a23 u 4R4 v
C.ei ei 0Po R 1.
ei 0Po R u u | ( PHP Fr amewor k Tut or i al i n Bangl a)
:
яo$ %
•
ei' Oo$ (PHP Framework) ,c e basic Platform/structure((>) 3 o$ a p D6E6 ^6 ,$।
•
( d6, like k : ei s A 6я 2n (like) 2,p6 я 6 ! , j e 6 i6 : e( e eA ep e u: ,।
•
PHP Framework , % ep D6E 3 @ ( -p' $ ', ! D6E 7
k,d6 a p D6E 6 ।
•
e2 N ! 3 ( e Ao ,я 6 ,e( 2 N o %o a @ %2 , я i 76 ।
,я $ ei' Oo$ (PHP Framework) e eA o$ 3 is : % ,яi e o$ i D6E 6 e %(
i a ! D6E । ei' Oo$ (PHP Framework) %( 3 ;$( я 6 , 1.PHP(; PHP Function, Variable etc) 2.Object Oriented Programming 3.MVC(Model View Controller)Structure a ei' Oo %2 3 яn Oo , , ,, !i( i i6 :।яn e !i( i ' яp 6 яn e я R- яn : en p iя ei' e я 3 ।6 i p io
Oo : я u'n 3 !i( i , , i6 :।e % !i( i (CodeIgniter PHP Framework) e u 2 ~ @ :$ 'c ।
2.
a яk aK 0pg2 e 2 ei ( OOP & PHP Tut or i al i n Bangl a)
: яo
яo %
p u aK 0pg20pg2- POP ( PROCEDURE ORI ENTED ENTED PROGRAMMI NG) u' 3 language 3 FORTRAN(Formula Translation-e Statistician ,
)COBOL,C i6 : , (6 (6 s i 3 p g , 6 @ 6 , Procedure Oriented Programming(POP).PHP :o e p g 3 ।POP (R6 , 2 : (instruction/actions) 6 ,ei : ( mu я।ei : ( g % s '6।e u p g e 2 2 a ( ,,p6A ai e p g e e + ! । , e u p g n ! я n , 2 e c e p g i % u6 ,।3 i, % 2 %2 POP 6 3 a @ 6 global data %k n , 36 6 e %o %2। a яk aK 0pg2 0pg2g2- OOP( OBJECT ORI ENTED PROGRAMMI NG) NG) OOP aяk an! p g (Object Oriented Programming) ei ( @ 2 k E @ e2।OOP ! critical element , ' e s ! k p , (free flow) n :।OOP e e @ Objects (R6,e @ я ei aяk( eA %A 3 ( 3 ( / sk /d k 6 m 6 /(interact) OOP *e ! k @ ( 3 ei ! operate ) *u p g Object % k ।a n e p g 2 2 a ( 3 Object *e Object e ! e ,ei A ! ' (Operate ) * i ei ! 6 e 6 । * d e Object % Object e 3 ( 3 ( 6 । *e p g 3 6 ! e 3 ( 3 । OOP 6 3( @ h 6 , • • • • • •
Objects Class Encapsulation Inheritence Polymorphism Message passing
a яk ( OBJECTS) aяk D6E , 2 ! e ! ,ei ! ! ( ' ) ।aяk ,c e ( 2 6 (a bundle) 3 ! e n D6E।e k , 2 u k।e aяk e k 6, k
3 2 я 6 aяko , ! ।k aяk ,c 2 ei' ! u।aяk :6 a 6( ! @)।কিন্তু e a o '। aяk an! ei' 6 % 3 ! ( : % e( 2 aяk e ( 2 /
/ 6 u (bunch).e g @ я ei aяk( et я ।e u: , ,6 e s n (ei' skpA), 3 %2 e(c e (bunch) ' E (aяk(),6 s n e я , 3 p6 ' E (aяk) я я я m : s6nt । k ei'( d6-Procrdure Oriented way) e 3: 6 6 , :
(bunch) skpi 2u ' ' । k ( CLASS) ei'
6
aяk
D6E
%(
%
ei
aяk
e
я
e
/e
l
(blueprint/template/outline)D6E 6 ,।e p (e aяk e я) k । k ,c aяk я (blueprint).e k ,c aяk я । 3 e 6 e l e
।e k 2 я 3 , a n e k e aяk m @ ।3 e aяk an! ei' ! 6 ei' e living,breathing aяk D6E k e u t ।living,breathing aяk 6 7 ,c ei aяk A 6 D6E ,। e4 s34 ( ENCAPSULATI ON) e k (class) e @ ! e i e ।e k eA k E Dc।e6 k 6 ! 6 i
e o 3 ।a n i ei ! 6 p 6 ।@ t 3: ei k 6i 6 , i Ai @ ei ! 6 e 6 । i
! ei e n , 3 o pk ! 6 (data hiding/information hiding) i4tn ( I NHERI TANCE) OOP 6 i,n ! g: , (reusability) @ p: ।a n e k a6k 2 3 ( 36 k A : 2 u i।@ % skp e k %2 e % % 6 k D6E 6 ei k a@E। kA , k k (super class/base class)% 3 k ( e
, ( k /p6 :6 k (subclass/derived class).extends ei o !A : k
eA 6 k 3 । 1я ( POLYMORPHI SM) e @ aяk e я ei , 3 n я , 6 ei pk я। 0 я ajk4 ( MESSAGE PASSI NG) e OO Program e e @ aяk e e e a 3 ( 3 ( a n e aяk % aяk e 2 я > ei pk i , я a6k।
(2।OOPHP ! D6E %( % ei' , ,n sn, i6 : @ 6 ,। Au A ,я e D@3 @ 6 23 A 2 2 a(@ ) ( ,2। \\- ^: pg ei 0я ijk r4 index.php class_lib.php % : aяk an! ! e i i iA % ei' ‘includes’ , ei' e я i :।ei Au я % : aяk an! ! class_lib.php i ।OOP % k D6E A яu6।k ,c mp/k aяk e я 3 p aяk m @ :। \\- : e ei k ijk ei' skp , !, i6 : 2u 2A 6 3 % aяk an! d66 ! 6 p i e k D6E 6 ,।k D6E я p i ‘class’ bA :6 , e e k ic6 :6 । 1.
\\- [: k 0 0qa k ,c aяk я bpn/ ।3 k 6 % e D6E 6 ei , ‘property’ 1.
:
e k 6 3 ! / (ei u: , var name;) , 6 e ‘properties’
\\- : k 1234/ 1234/0g 0qa e k 6 e 3 , 3 ‘properties’ 6 e k 6 e 6 , 3 ‘methods’ ( 6 k 6 6 e: ei ! , )e k !/methods i k ! /properties 6 ^6 ,। name=$new_name; } function
get_name(){
return $this->name; } } ?>
k 6 properties e 6 ,। \\- `: getter e 2 setter 1234 % :A / ! D6E 2 get_name() e set_name() ei (я eA E6 ' 6 , e k getter e setter ai property । name=$new_name; } function get_name(){ return $this->name; } } ?>
e k getter e setter property 2।e6 3 ei' p g % aяk я 6 3i t % set_name() / ! : 6 7 3 e ai e property/variable 3 , ‘name’ \\- : ‘$t $t hi s’ s 0
! m6 ' iA :2 $this->name=$new_name
$this e li ( aяki e l i) 3 6 aяk : ।a e e selfreferencing ।e , properties e e 3 e e ! 6 k 3 । function get_name() { return $this->name; }
76 3: , 6 , e 3 e e ei' o ! e 3 ei' ! ei 6 ei' iя 7 6 6 ,।
\\- : 9 ei 0я ei k 9 4 ei' я ei k 6 , aяk an! p g e udi ,।' , k % : e ei' я D6E ei' я e ‘include’ ‘require’ : 3 ( : । OOPHP in Webcoachbd
% n eo k : 2 ,e ,। \\- : a яk ijk e k aяk D6E pk instantiation. $rejoan = new people();
$rejoan 6 D6E people aяk e я n।% $rejoan , ei people aяk nt e , я।
\\- : new oR e k 6 aяk D6E 6 % ei new o !A p я ,। % ic e k a aяk D6E 6 ।ei' iя 2 p6A aяk % : % : (s6nt st ) $rejoan = new people(); $riad = new people;