You are on page 1of 67

ei

A.ei

1.

is

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 1 234 u   ( PHP Dat e Funct i on Tut or i al i n Bangl a)
3.ei i4k9 1 234 u   ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)
equi
4.ei    1 234 ( PHP r eq
ui r e Funct i on Tut or i al i n Bangl a)
5.ei 1 i 1 234 u   ( PHP Fi l e Funct i on Tut or i al i n Bangl a)
6.ei 1 i ?  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 h K  u   ( PHP Er r or Handl er Tut or i al i n Bangl a)
10. ei 0i 1 234 ( 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 0p g 2 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 ia4 i   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 ia4 i  41a   ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)

7.0 ia4 i 
0 ia4 i  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  %   be ,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  2e o$ (  O  o$ 3 $P$ e6k ((  ' :$ o$ (
  2e  , 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 e A %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 j t ei 01 l  htdocs 4  ?  01 l  ?v


0 o 4 ?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 <?php 'h :$  e ?> 'h :$
; ,
* e  ei' Scripting Block(<?php e ?> e 6 3
 ,$
 $ e  b ) !kn 6 6
 
*p6A % : instruction(code line)
k  d 
; ,
o e  % 
! e! (
  !/U$   % 3  ,  )  e ' 6 
<?php
echo"This is my first php page";
?>

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
'$2e 
 i n   6 ' i //  # % ,  i n   6 ' i
! %( /* e
; */ 'h  ,  6
,
 : a p A ,
3 k 2
 ki3 <?php e ?>
! 6
echo
"Hello
World!
echo
"Hello
World!
echo
"Hello
World!
echo
"Hello
World!
echo
"Hello
World!

";
";
";
";
";

e 6 k
<?php
echo "Hello World!";
echo "Hello World!";
?>

%    
: 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      

6ei'
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.<?php
2.$hello = "Hello World!";
3.$a_number = 4;
4.$anotherNumber = 8;
5.?>

*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  '
: e i s :  D6E 2,e    $ store  ,$2 %     echo  ,$2
1.<?php
2.$my_string = "o merciful make me bold and brave!";
3.echo " o merciful make me bold and brave!";
4.echo $my_string;
5.?>

u u: , p  s


$my_string  $ i  $
:$ ,$2 % d6E$  %  s
echo  ,$2,

 $  store ie    $  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.<?php
2.$my_string = o merciful make me bold and brave!;
3.echo o merciful make me bold and brave!;
4.echo $my_string;
5.?>

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  6 6 
  s
! 6 ,  , 7  ,'
:    e 6 ,$1.<?php
2.$my_string = <<<TEST
3.He will be succeeded here
4.and here after!
5.TEST;
6.echo $my_string;
7.?>

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 % <br>( 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

English

Example

Addition

2+4

Subtraction

6-2

Multiplication

5*3

Division

15/3

Modulus

43%10

01.<?php
02.$addition = 2 + 4;
03.$subtraction = 6 - 2;
04.$multiplication = 5 * 3;
05.$division = 15 / 3;
06.$modulus = 5 % 2;
07.echo "Perform addition: 2 + 4 = ".$addition."<br />";
08.echo "Perform subtraction: 6 - 2 = ".$subtraction."<br />";
09.echo "Perform multiplication: 5 * 3 = ".$multiplication."<br />";
10.echo "Perform division: 15 / 3 = ".$division."<br />";
11.echo "Perform modulus: 5 % 2 = " . $modulus ?>

      e
: -

j94 9 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
*ifelse statement
*ifelseifelse 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.<?php
2.$d=date("D");
3.if ($d=="Sat")
4.echo "Have a nice Day";
5.?>

* I FELSE
F ELSE STATEMENT
%c o
6 e 2 3: k  6 ,     , , 3: k  ,
ie i ifelse statement
e u: ,e( 6 a $ %  si  ,    e @ e  ei'
! :$ 
1.<?php
2.$d=date("D");
3.if ($d=="Sat") echo "Have a nice Day";
4.else
5.echo Today is not saturday;
6.?>

: condition
3 :$2 3:
 true ,$ a  n
!
3:    
: 3: Saturday ,$ 6 , %u ,
Have a nice day % 6  , Today is not Saturday.
* I FELSEI
F ELSEI FELSE
F ELSE STATEMENT
ei statement d  e  e @
! b execute  3 $
view source
print?
01.<html>
02.<body>
03.<?php
04.if ($number>=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.</body>
14.</html>

9.

ei 9 u   ( PHP Loop Tut or i al i n Bangl a)


 :


o$  %

% e    6 % :  i     (


3 e i  50 i e @    @ e i 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
Dowhile 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  'i3:
01.<html>
02.<body>
03.<?php
04.$i=1;
05.while($i<=5)
06.{
07.echo "The number is " . $i . "<br />";
08.$i++;
09.}
10.?>
11.</body>
12.</html>

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
,
DOW
DO WHI LE LOOP
e while loop e 6i @   e k
3 condition A
; test  ,$, 6   6,
3 ,$ while 
ea 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 e i %u
: @  n 
01.<?php
02.$i=1;
03.do
04.{
05.$i++;
06.echo "The number is " . $i . "<br />";
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 ,$2p   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.<?php
2.for ($i=1; $i<=5; $i++)
3.{
4.echo "The number is " . $i . "<br />";
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   e A6 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   te  a  ,
 2 u :   (R6
3  p6 A 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.<?php
2.$city=array(Dhaka, Chittagong, Rajshahi, Sylet, Khulna,
Barishal, Barishal);
3.?>

  e  variable e  ,   store ,


(2,p6A ,   e e A u :  e p6A u :  e A index
:c , (2array 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.<?php
2.Print $city[3];
3.?>

6 3: % ' i 6 , a  ei !l   6  :6  ,=> ei a A :@ % ' c ei u
a A starting index 2 : 
, 6 , e  6 ,
1.<?php
2.$city=array(2=>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.<?php
2.$ages = array("adnan"=>32, "rezwan"=>30,"refat"=>34);
3.?>

 l i434  a
 ( MULTI DI MENSI ONAL ARRAY)
ARRAY)
e  e  a  6 p6A u :  e A a  ,6   %  ei   a  p6A u : o e A a  ,6   e
e  %o
1.<?php
2.
3.$continents=array("Asia"=>array("Bangladesh","India","Pakistan"),
4."Europe"=>array("England","France")"Africa"=>array("Kenya",
5."Libya","Somalia"));
6.
7.?>

a
 r 92

FOREACH LOOP
@ e A associative array %2 e  % g bt 6 '  foreach statement : e 6  3:
1.<?php
2.$city=array(Dhaka, Chittagong, Rajshahi, Sylet, Khulna,
Barishal, Barishal);
3.foreach ($city as $value)
4.{
5.echo $value.<br>;
6.}
7.?>

Output
Dhaka
Chittagong
Rajshahi
Sylet
Khulna
Barishal
Barishal

13.

ei 1 234 u   ( PHP Funct i on)


 :


o  %

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.<?php

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
1 234 
   0q a
0q a 
     
3 (  %o   A  u  3 ,e e : PHP variable e 6i   
   e
b   6
 ,3
01.<?php
02.function writeName($fname)
03.{
04.echo $fname . " Alam.<br />";
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: ,

is

Rejoanul
Samad

Alam.
Alam.

01.<?php
02.function myGreeting($firstName, $lastName){
03.echo "Hello there ". $firstName ." ". $lastName."!<br />";
04.}
05.myGreeting("Jack", "Black");
06.myGreeting("Ahmed", "Zewail");
07.myGreeting("Julie", "Roberts");
08.myGreeting("Charles", "Schwab");
09.?>

output
Hello
there
Hello
there
Hello
there
Hello there Charles Schwab!

Jack
Ahmed
Julie

Black!
Zewail!
Roberts!

e      return 6 return statement  ,  6 ,3


view source
print?
01.<?php
02.function add($x,$y)
03.{
04.$total=$x+$y;
05.return $total;
06.}
07.
08.echo "1 + 16 = " . add(1,16);
09.?>

14.

ei 1R u   ( PHP For m)


 :


o$  %

e6k ei' 36  2
 , e  6 p$ ( $ e2 iu 
 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 % e A     %2
1.<form action="welcome.php" method="post">
2.Name: <input name="fname" />
3.Age: <input name="age" />
4.<input type="submit" />
5.</form>

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 <?php echo $_POST["fname"]; ?>!<br />
2.You are <?php echo $_POST["age"]; ?> 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  e A E %2  @ 6  c 250 A character (e %    e b u  u  
3 6 : URL e
D:a 6: ,)
3
1.<form action="welcome.php"method="get">
2.Name: <input name="fname" />
3.Age: <input name="age" />
4.<input />
5.</form>

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 <?php echo $_GET["fname"]; ?>.<br />
2.You are <?php echo $_GET["age"]; ?> years old!

16.

ei 0 s 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 $)
<form action="welcome.php" method="post">
Name: <input name="fname" />
Age: <input name="age" />
<input />

</form>

e  3 iu      k  6 b u  eU  ' 6


: 
http://www.w3schools.com/welcome.php
% e  
! $_POST Method d66 (b,E6 ,
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> 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 1 234 u   ( PHP Dat e Funct i on Tut or i al i n Bangl a)


 :


o  %

ei 0 1 234 ( PHP DATE FUNCTI ON)


% %  o
  | 6  6 /
: 6 ' i6   6 ei' e date()   d  eA 6
 3
view source
print?
1.<?php
2.echo date("Y/m/d") . "<br />";
3.echo date("Y.m.d") . "<br />";
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 1 234 u   ( PHP I ncl ude Funct i on Tut or i al i n
Bangl a)


 :


o$  %

% ic i    ek u   %(i ei' e e   i a a %  ei'  i i  $ :6  
include()   :$
Require()-  , fatal error((6  )
:  e skpA ek u  n  :
Include()-  , 6  : e skpA ek u 
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.<a
2.<a
3.<a
4.<a
5.<a
6.<a

href="/default.php">Home</a>
href="/tutorials.php">Tutorials</a>
href="/references.php">References</a>
href="/examples.php">Examples</a>
href="/about.php">About Us</a>
href="/contact.php">Contact Us</a>

e 
3 ( 6 , e 
view source
print?
01.<html>
02.<body>
03.<div>
04.<?php include("menu.php"); ?>
05.</div>
06.<h1>Welcome to my home page.</h1>
07.<p>Some text.</p>
08.</body>
09.</html>

4.

ei    1 234 ( 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.<html>
02.<body>
03.
04.<?php
05.include("wrongFile.php");
06.echo "Hello World!";
07.?>
08.</body>
09.</html>

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.<html>
2.<body>
3.<?php
4.require("wrongFile.php");
5.echo "Hello World!";
6.?>
7.</body>
8.</html>

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  ek u ,$ i

in

open
C:\home\website\test.php

error: require()
required

[function.require
stream
on
line

[function.require
'wrongFile.php

5.

ei 1 i 1 234 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.<html>
2.<body>
3.<?php
4.$file=fopen("welcome.txt","r");
5.?>
6.</body>
7.</html>

fopen e b   :A  %2 e A welcome.txta  n ei    iA  e d6EA r e e 
   
3 : R 
: 3   iA
 as (
 !)ge  r
: %2 6 i eA read only
 ! 
e  %  2    
Modes

Description

Read only. Starts at the beginning of the file

r+

Read/Write. Starts at the beginning of the file

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

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

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.<html>
2.<body>
3.<?php
4.$file=fopen("welcome.txt","r") or exit("Unable to open file!");
5.?>
6.</body>
7.</html>

e  1 i 0k 

fclose() function :


 
  i n  3 
1.<?php
2.$file = fopen("test.txt","r");
3.
4.//some code to be executed
5.
6.fclose($file);
7.?>

ENDEND- OFOF- FILE 0 


e :  i
;
~2    6
'  ,
if (feof($file)) echo "End of file";
e  e    (
e  1 i LINE BY LINE 
fgets() function A : ei'
6 e A e A   i u 3 ei  A         i : A 
 i ' 3 ' u: ,
: eA e A e A   i u
; 
~2 3n
01.<?php
02.$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
03.//Output a line of the file until the end is reached
04.while(!feof($file))
05.{
06.echo fgets($file). "<br />";
07.}
08.fclose($file);
09.?>

CHARACTER BY CHARACTER
CHARACTER e  1 i 
fgetc() function A e   i
 e  e   ak u
' u: ,A  i
 e A e A  ak u
view source
print?
1.<?php
2.$file=fopen("welcome.txt","r") or exit("Unable to open file!");
3.while (!feof($file))
4.{
5.echo fgetc($file);
6.}
7.fclose($file);
8.?>

6.

ei 1 i ?  u   ( PHP Fi l e Upl oad Tut or i al i n


Bangl a)


 :


o  %

ei    @ iu  %      i % ! 6  3


01.<html>
02.<body>
03.
04.<form action="upload_file.php" method="post"
05.enctype="multipart/form-data">
06.<label for="file">Filename:</label>
07.<input />
08.<br />
09.<input type="submit" name="Submit"value="Submit" />
10.</form>
11.</body>
12.</html>

e  action="upload_file.php" e method="post"


: ,2 a  n     k  
! (

 s
 ! e  @ upload_file.php    i 3 e 
: upload_file.php
6
! (  e  
Upload_file.php skpA , e 
01.<?php
02.if ($_FILES["file"]["error"] > 0)
03.{
04.echo "Error: " . $_FILES["file"]["error"] . "<br />";
05.}
06.else
07.{
08.echo "Upload: " . $_FILES["file"]["name"] . "<br />";
09.echo "Type: " . $_FILES["file"]["type"] . "<br />";
10.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
11.echo "Stored in: " . $_FILES["file"]["tmp_name"];
12.}
13.?>

global PHP $_FILES a   ,   % k in mu 


       i % ! 6  

$_FILES["file"]["name"] % ! b 6  i  

$_FILES["file"]["type"] - % ! b 6  i type

$_FILES["file"]["size"] - % ! b 6  i size

$_FILES["file"]["tmp_name"] % ! b 6  i temporary copy


3    k6 

% ic   i


e  % ! 6   6 R  :6    t   3 6
3 
u
3   i
% ! 6   3 20    i a@    i % ! 6    @ .jpeg,.jpg,.gif  
 i % ! 6   i6 : R  :6  

01.<?php
02.if ((($_FILES["file"]["type"] == "image/gif")
03.|| ($_FILES["file"]["type"] == "image/jpeg")
04.|| ($_FILES["file"]["type"] == "image/pjpeg"))
05.&& ($_FILES["file"]["size"] < 20000))
06.{
07.if ($_FILES["file"]["error"] > 0)
08.{
09.echo "Error: " . $_FILES["file"]["error"] . "<br />";
10.}
11.else
12.{
13.echo "Upload: " . $_FILES["file"]["name"] . "<br />";
14.echo "Type: " . $_FILES["file"]["type"] . "<br />";
15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
16.echo "Stored in: " . $_FILES["file"]["tmp_name"];
17.}
18.}
19.else
20.{
21.echo "Invalid file";
22.}
23.?>

?  j 1 i 0    o
%(i 2 u
!( :     i as E(temporary copy)  
 ,,s E      e 
!A

01.<?php
02.if ((($_FILES["file"]["type"] == "image/gif")
03.|| ($_FILES["file"]["type"] == "image/jpeg")
04.|| ($_FILES["file"]["type"] == "image/pjpeg"))
05.&& ($_FILES["file"]["size"] < 20000))
06.{
07.if ($_FILES["file"]["error"] > 0)
08.{
09.echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
10.}
11.else
12.{
13.echo "Upload: " . $_FILES["file"]["name"] . "<br />";
14.echo "Type: " . $_FILES["file"]["type"] . "<br />";
15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
16.echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
17.
18.if (file_exists("upload/" . $_FILES["file"]["name"]))
19.{
20.echo $_FILES["file"]["name"] . " already exists. ";
21.}
22.else
23.{

24.move_uploaded_file($_FILES["file"]["tmp_name"],
25."upload/" . $_FILES["file"]["name"]);
26.echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
27.}
28.}
29.}
30.else
31.{
32.echo "Invalid file";
33.}
34.?>

skpA
: %(
 i ei  
  i    %2   ,  move_uploaded_file  A  , 3 :c b 6

 l  (  iA
 ,
u u: , upload   e 
 l  (  iA
 ,

7.

ei k u   ( PHP Cooki e Tut or i al i n Bangl a)


 :


o  %

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 <html>  ( e %( 6 ,
setcookie(name, value, expiration);
namename:e k   , ei  A  ,  6 , k A
n
6
value:e k 6   k   ,,   ^6 k ,c username(string)e last visit(date)
expiration:e oi  3 k A
 :
; ,3: % ei
 : 6 A(k A 6k )R  
:
6 , b u  s        i k A 2 3 
' u: , % e A 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 :  :2a  n e  oi s iu  ignore  ,2 3  30 : 6 e  
 i
i  
1.<?php
2.$expire=time()+60*60*24*30;

3.setcookie("user", "rezwan",$expire);
4.?>
5.<html>
6......

k ud  (RETRIEVE)
RETRIEVE) 
3: k 
 :
;  ,  6 , ei' $_COOKIE variable : k retrieve  3 
1.<?php
2.if(isset($_COOKIE['lastVisit']))
3.$visit = $_COOKIE['lastVisit'];
4.else
5.echo "You've got some stale cookies!";
6.
7.echo "Your last visit was - ". $visit;
8.?>

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.<?php
2.// set the expiration date to one hour ago
3.setcookie("user", "", time()-3600);
4.?>

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    @  :2ei'
 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 <html> tag e %(  6 ,
1.<?php session_start(); ?>
2.
3.<html>
4.<body>

5.
6.</body>
7.</html>

ei !A     , 3 iu 



s   e ei
 e  %i! : 6  6 
   
0 34 
  2k4
2k4 

 6  k o ud  R u  ,


   $_SESSION  ,  
01.<?php
02.session_start();
03.// store session data
04.$_SESSION['views']=1;
05.?>
06.<html>
07.<body>
08.
09.<?php
10.//retrieve session data
11.echo "Pageviews=".$_SESSION['views'];
12.?>
13.
14.</body>
15.</html>

%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 , viewsvariable D6E  e e  1


:
01.<?php
02.session_start();
03.
04.if(isset($_SESSION['views']))
05.$_SESSION['views']=$_SESSION['views']+1;
06.else
07.$_SESSION['views']=1;
08.echo "Views=". $_SESSION['views'];
09.?>

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.<?php
2.unset($_SESSION['views']);
3.?>

e 
 mg   6 session_destroy() function  ^6 ,
1.<?php
2.session_destroy();
3.?>

session_destroy()
 reset  e e6 
   
  6  ,  

9.

ei e h K  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 ee A (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 h K 
e e 
2 
!
3
kk  i 
1.<?php
2.$file=fopen("welcome.txt","r");
3.?>

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.<?php
02.if(!file_exists("welcome.txt"))
03.{
04.die("File not found");
05.}
06.else
07.{
08.$file=fopen("welcome.txt","r");
09.}
10.?>

e  3:  iA    6 , ei



: 
File not found

to

open

stream:

ei
!A u
!
' e  ne e   @  d6 e6 error , skp n , 3 6 e d6  ,  
a  R 
s e h K 
h K  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  1 234 ijk  e h K e n
1.function customError($errno, $errstr)
2.{
3.echo "<b>Error:</b> [$errno] $errstr<br />";

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 h K  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.<?php
02.//error handler function
03.function customError($errno, $errstr)
04.{
05.echo "<b>Error:</b> [$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.<?php
2.$test=2;
3.if ($test>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.<?php
02.//error handler function
03.function customError($errno, $errstr)
04.{
05.echo "<b>Error:</b> [$errno] $errstr<br />";
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

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 t q
e 0  4
<?php
//error
function
{
echo
echo

handler
customError($errno,
"<b>Error:</b>
"Webmaster

[$errno]
has

function
$errstr)
$errstr<br
been

/>";
notified";

error_log("Error:
[$errno]
" someone@example.com","From: webmaster@example.com");
}

$errstr",1,

//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

must

or

be

below",E_USER_WARNING);

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   i b 6
!
k
o  
!
  


! 
  

1 234 e 2 1l 

   filter 6 '  (  ,   ,

filter_var() :c e  l  : e    filter 

filter_var_array() e i  n l  : e @   l  

filter_input e    i   e l  

filter_input_array e @   i   e e i  n l  : l  

' u: , filter_var() function : e  g validate 

01.<?php
02.$int = 123;
03.
04.if(!filter_var($int, FILTER_VALIDATE_INT))
05.{
06.echo("Integer is not valid");
07.}
08.else
09.{
10.echo("Integer is valid");
11.}
12.?>

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: , e A g   validate 6 filter_var() l  e "min_range" o "max_range"
option  ,   ,2
01.<?php
02.$var=300;
03.
04.$int_options = array(
05."options"=>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 i b 6
!
3 % 2 6  ast %2   6  filter_input() function d 
i b 6
!  l  6 ,u: ,
01.<?php
02.if(!filter_has_var(INPUT_GET, "email"))
03.{
04.echo("Input type does not exist");
05.}
06.else
07.{
08.if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL))
09.{
10.echo "E-Mail is not valid";
11.}
12.else
13.{
14.echo "E-Mail is valid";
15.}
16.}
17.?>

  :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 i b 6
!
3 % 2 6  ast %2   6  filter_input() function d 
i b 6
!  sanitize 6 ,u: ,
01.<?php
02.if(!filter_has_var(INPUT_POST, "url"))

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.W3Schools.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.<?php
02.$filters = array
03.(
04."name" => 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.<br />");

25.}
26.elseif(!$result["email"])
27.{
28.echo("E-Mail is not valid.<br />");
29.}
30.else
31.{
32.echo("User input is valid");
33.}
34.?>

11.

ei 0i 1 234 ( 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      
(2a  n !
e    ei'
i  ' u: , e A
k
  >  ,2 p
i 3 2
(a  n someone@example.com ei
i)
PHP MAI L FORM
<html>

<body>
<?php
if
(isset($_REQUEST['email']))
//if
"email"
is
filled
out,
send
email
{
//send
email
$email
=
$_REQUEST['email']
;
$subject
=
$_REQUEST['subject']
;
$message
=
$_REQUEST['message']
;
mail(
" someone@example.com",
"Subject:
$subject",
$message,
"From:
$email"
);
echo
"Thank
you
for
using
our
mail
form";
}
else
//if
"email"
is
not
filled
out,
display
the
form
{
echo
"<form
method='post'
action='mailform.php'>
Email:
<input
name='email'
type='text'
/><br
/>
Subject:
<input
name='subject'
type='text'
/><br
/>
Message:<br
/>
<textarea
name='message'
rows='15'
cols='40'>
</textarea><br
/>
<input
type='submit'
/>
</form>";
}
?>
</body>
</html>

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 4 r dj 4 ej  ei 1R
t   a \ iu  0i  rj  
e   ii i4 34ii 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 e A 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 e A 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 0p g 2 e 2 ei ( OOP & PHP Tut or i al i n Bangl a)


 :
o 


o  %

p u aK 0p g 20p g 2- 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      
'6e  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 0p g 2
0p g 2g 2- OOP( OBJECT ORI ENTED PROGRAMMI NG)
NG)
OOP  ak an!
p g  (Object Oriented Programming) ei  (  @   2 k E @  
e2OOP
!  critical element , '  e s
!  k p , (free flow) n 
:OOP
e  e @ Objects  (R6,e    @   ei ak( e A % 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)
ak D6E ,  2
! e
! ,ei
!
!    (  '  ) ak ,c e 
( 2  6
(a bundle) 3
! e   n D6Ee   k  
,
2   u  ke  ak e   k 6, k


3  2  
6 ako   ,
! k ak ,c  2 ei'
!
 u ak
:6
a    6(
! @) e a  o    
'
ak an! ei'
6 %
3 ! (
: % e(  2 ak e
( 2 /
/
6 u (bunch).e  g 
 @   ei ak( e t e  u: , ,6   e 
s n (ei'  skpA),
3  %2 e (c
 e  (bunch) ' E (ak(),6 
s n e   ,
3  p6 ' E (ak)  
  m :  s6nt 
k  ei'(  d6-Procrdure Oriented way) e   3: 6   6 ,
:
   

(bunch)   skpi 2u   '    ' 


k ( CLASS)
ei'

ak

D6E

%(

% 

ei

ak

e



e 

  /e 

 l

(blueprint/template/outline)D6E 6 ,e 


p (e  ak e ) k  
k  ,c ak    (blueprint).e  k  ,c ak  
3 e    6 e  l e 
 e  k   2
 
3
,  a  n e  k  e  ak m @  3 e 
ak an! ei'
!    6 ei' e  living,breathing ak D6E  k  e u t
living,breathing ak 6 7  ,c ei ak A   
6 D6E ,
e4
s34 ( ENCAPSULATI ON)
e  k  (class) e @
!    e  i e   e k  e A k E Dce6  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 
 e A 6  k 
  3 
1 ( POLYMORPHI SM)
e @ ak e  e i    ,   3 n  , 6 ei pk   
0 ajk4 ( MESSAGE PASSI NG)
e  OO Program e e @ ak  e e e a  
3 ( 3 (   a  n e  ak % 
ak e 2
  >  ei pk i ,
 a6k

3.

[ \  a k aK ei ( OOPHP Tut or i al i n Bangl a)

e1 1  u4  j  4 0 R 0 


0  eo 4
6  ei' 5 (PHP5)   '2ei' 5 mg ak an!e %(   ei' 4 mg ak
an! 2 ei' 5 ak an! ,o 6 e : A, , 3 (,!   o ep  D6E , ,

(2OOPHP
! 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
% : ak an!
! e   i 
i  iA % ei' includes    ,   ei'
e   
 i  
:ei Au    % :  ak an!
! class_lib.php  i OOP
% k  D6E   A   u6k  ,c
mp/k   ak e  3 p ak m @ 
:
\ \ - :
e  ei k ijk 
ei' skp  ,
!,
 i6 : 2u 2A    6 3 % ak an! d66
!  6
p i e  k  D6E  6 ,k  D6E  p i class bA :6 , e e k    ic6 :6  
1.<?php
2.class people{
3.
4.}
5.?>

\ \ - [:
k  0 0q a 
k  ,c ak  bpn/  3 k  6 % e 
 D6E  6 ei
  ,
property
1.<?php
2.class people{
3.var name;
4.}
5.?>

 :

  e  k  6 3


! /
(ei u: , var name;)   , 6 e   properties

\ \ - :
k  1 234/
1 234/0g 0q a 
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 ,
<?php
class people{
var $name;
function set_name($new_name){
$this->name=$new_name;
}
function

get_name(){

return $this->name;
}
}
?>

k  6
 properties  e   6 ,
\ \ - `:
getter e 2 setter 1 234
% :A  /
 ! D6E 2 get_name() e set_name() ei  ( e A E6
 ' 6 ,
e  k  getter e setter   ai property     
<?php
class people{
var $name;
function set_name($new_name){
$this->name=$new_name;
}
function get_name(){
return $this->name;
}
}
?>

e  k  getter e setter   property     2e6  3


 ei'
p g  
%  ak   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
 ( aki e l i)
3 6  ak : 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 , ak an!
p g  e udi  ,'   , k 
% : e  ei'
 D6E   ei'
 e include  require :
3 ( 
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//BN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
<title>OOPHP in Webcoachbd</title>
<?php include("class_lib.php"); ?>
</head>
<body>
</body>
</html>

%  n eo k  :  2 ,e   ,


\ \ - :
a k ijk 
e  k  ak D6E pk   instantiation.
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
</body>
</html>

$rejoan
 6  D6E people ak e 
 n% $rejoan  ,   ei people
ak nt e  ,    

\ \ - :
new  o R
e  k  6 ak D6E 6 %  ei new  o !A p  ,
% ic  e  k  a ak D6E 6  ei' i 2 p6A ak % : % : (s6nt
st )
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
$riad = new people;
</body>
</html>

ak D6E  k  @ quote : 6 ,   ,a  n ' e   
$rejoan= new 'people';

\ \ - ^:
a k properties  (set)
set) 
% :A ak D6E 2 people  ,e % 6 : properties R (set)  :6   p

 !A(the setters) ,  


3 %( D6E  
e   6 ,
3 3:o % : ak e  2A($rejoan e $riad) e i k  people e u t
 D6E  ,2ei'  n 6 : mg % : , '  a  n ei' e  2A ak
: 3
mg % : % :
<?php include("class_lib.php"); ?>
</head>
<body>
<?php

$rejoan = new people();


$riad= new people;
$rejoan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
?>
</body>
</html>

\ \ - ^^:
a k 0 j e  04
e % getter
 !A ,   ak
! 6 e  6e ,
i
! 3 % setter
 ! :
ak i  2 
3 % k 
 ! e properties e e 
i 6 a  (->)'hA  ,  
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people();
$riad = new people;
$rejoan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
echo "Riad's full name: " . $riad->get_name();
?>
</body>
</html>

 :ei a  (->) 'h % e A a  (=>) ei 'h  n e 

an % ei Au   a@


; 

3 3 :
e  ei' k  ! i 
ei k  u t  e  u ak D6E 
ak
! i 

ak

! 6  %
@ -12:
  a k properties e e  04 ?
04 ? e  44
ak properties e e 
6 % 

 ! ,  6 , ,%   a  (->) a 
 ,   e  6  u: ,s:
$rejoan->name.

3:o e  3  6o e      e e    d6e    7  (  ,6  '  


, getter
 ! ,  
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people();
$riad = new people;
$stefan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
// directly accessing properties in a class is a no-no.
echo "Rejoans full name: " . $rejoan->name;
?>
</body>
</html>

\ \ - ^[:
4sT k
 ak e  li
 ! %2 6 , s ke %  ak properties e  
:

 :__construct()
  A D6E  ei' a A __construct  /
 !   3 %

 
e  k  6 e  ak D6E 
construct
 ! :A %n s  (__):  , s k
 !  k    e 6   2 3k 6 
(e    6) :  @ 6 ei
 ! bd  , 

<?php
class people {
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>

ei Au   k6   


functions=methods
variables=properties

@ -14:
construct r e  a k 0jk 
% e  s k
 ! D6E 2,e % people ak D6E  $name property   :
:6  u: ,:
$rejoan = new people("Rejoanul Alam");

e % : set_name()
 !  
  '
:e6 
!   skp  3 
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoans full Name: " . $rejoan->get_name();
?>
</body>

</html>

e e 
2 u: ,
3 
:
( ak an! ei' e li
~ (mechanism)   
!
  
: 
!    ei E6
\ \ - ^`:
properties e e  1  
t   e  k d 
ak an!
p g  e e  E6 , e   (encapsulation).e %  ak
! s ' 
(properties) e e  E d 
:
k  properties e e  E d    access modifier ,   ,3A e  !   %21. public
2. private
3. protected
!l , public 
<?php
class people {
var $name;
public $height;
protected $social_insurance;
private $pinn_number;
function __construct($people_name) {
$this->name = $people_name;
<i>} </i>
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>

 : var  o ! :
 properties
a ; (declare)  6 e  public , @ ,

@ -16:
properties e e  k d  a23  a23-
3 e  property
private
a ;  , 6 @
  e i k  e  6  
3 property
protected
a ;  , 6 @ t e i k  e p6 :6 k  (derived class/ei
k A p k 
 p6 :6 ,o k 
3 k A properties e e  2) ei :A k 
  e  6
   e i k  e p p6:6 k  3
 k 

 ,2
public 
 E d6
i
3 u skp
3  (
 e6 e  6  
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
/*

3,6 $pinn_number
private
a ;  ,2 6 i ei
! e    ,
(,
p g     i
:6
   
:
*/
echo "Tell me private stuff: " . $rejoan->$pinn_number;
?>
</body>
</html>

\ \ - ^:
0g e  k d 
properties e 6
 !o % ei 3A e  !   ,   e  nt 6  
1.

public

2.

private

3.

protected

%
 e  !   ,  ?
ut:  e6 % e R  :6  
3,%  D6E  k A a ei'
p g      ,  ei
@ 
 e  (tg 6 
 % 6 , e  u
p k e   a ei'
p g   6   e
6 i  o , 

<?php
class people {
var $name;
public $height;
protected $social_insurance;
private $pinn_number;
function __construct($people_name) {
$this->name = $people_name;
}
private function get_pinn_number() {
return $this->$pinn_number;
}
}
?>

 :
3,6 get_pinn_number() eA private 6 i ei
 !A @ t
3 k  %2,p k 
 ,  
3 3: skp a
o
 ei
 !  6 '  6 , public
a ; 6 ,

\ \ - ^:
0  4:
t :

t :i4tn
ak an!
p g  e i,n (Inheritence) e 
~ Dc 3  d  % e  k  a
k /k (
 k  , ,  6  

 e  ,?
ut:e d  %
 k 
! g: ,  6  @ % e  6  k  D6E 6 ' c 3   
employee
3,6 employee e @ people/person 6 i 6  e i
 ! e properties

  
e  @  D6E ,2
6 ?
ei @ as  i,n % 
! 
: e 7 7  6   % e i
! g:, 
2 :A % : k  n e   d6 ei'
! 6 
1.  skp %  @ e  
!(  i 6 ,
2.
3,6 %
! g:^6 ,c 6 i e a (a) k  ^6 ,6    n
!(  i e  i 6
,a  ei' includes() e 6  ,

// 'extends' ei  o !A i,n
' 
class employee extends people {
function __construct($employee_name) {
}

\ \ - ^:
0  4:
t a23
t a23-

3,6 employee k A
 k  people

 ,2 6 i employee k A a A people k 
  public properties,
 ! ei k 
 3 (a  6   ei k  , 3 )
// 'extends' ei  o !A i,n
' 
class employee extends people {
function __construct($employee_name) {
$this->set_name($employee_name);
}
}

k     employee k  set_name()


 ! ,   3:o ei
 !A employee k 
a ;
(declare)   i  ei
 !A i6 @ % people k  ,  2
@ -20:
0  4:
t a23
t a23- [
'
!
: % employee ak get_name()
 ! ,  6   people k 
~e
e    d6 u: ,
3 
! 
 , (e i  /
 ! : 
 , )
<title>OOPHP in Webcoachbd</title>
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
// Using our PHP objects in our PHP pages.
$rejoan = new people("Rejoanul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
$riad = new employee("Anjirul Alam");

echo "Riads full name " . $riad->get_name();


?>
</body>
</html>

\ \ - ^:
0g Over r i ddi ng
 7  7 (3 i,n ,   ,) e 
 !
 k 
     e 6   p  ,6
 
u: ,s @ set_name()
 !A people k  3 2 6
 n  2 employee k  6 ,
%  n people k  set_name()
 ! Override 2 employee k  ei e i
 !A
a ;

<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' ei  o !A i,n Dc
' 
class employee extends people {
protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
}

function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>

k  set_name()


 !A people k  (
 k )    2 %    n  employee k 
  ,
@ -22:
0g Overriding.
Overriding.a23a23- [
o % 
 k 
 ! e 
  (6  ,
3i
 !
 k 
 p: :6 k  (e  child k o
) override 2
' u: , % employee k  set_name()
 ! override 2 e %
! e  
people::set_name($new_name);
e6 parent k  (People) set_name()
 ! % e  6  
<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' is the keyword that enables inheritance
class employee extends people {
protected function set_name($new_name) {

if ($new_name == "Stefan Sucks") {


$this->name = $new_name;
}
else if($new_name == "Anjirul

Alam") {

people::set_name($new_name);
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>

\ \ - [:
0g overriding a23a23- [
'people::set_name()' eA ei' i 
3 6  people k  set_name()
 ! 


%    d6 %2
3  % parent  o !A ,   6  k  parent k  (
 k 
parent k   3 )
:  :6  
<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' is the keyword that enables inheritance

class employee extends people {


protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
else if($new_name == "Anjirul Alam") {
parent::set_name($new_name);
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>

03 g :
g :
ak an!
p g  e e :
~ ; : % 
(e  OOPHP e (6   %(  % 
 a , ,
(e OOP
6 %  :k6 bd  e    :6   6 , e 
!   

,
!   6  3 6  6  ak D6E  %  e : n @  
'c
e@ 8/10 A
! D6E  e6 
: ak % k    ( 6 , ,
(2 %  2
OOP e 2 ?4  0p g 2
 
ak an!
p g  o  D6E e  %@ d6a@   ( e ei
 ! ,  23
 ,ei',,++ i6 :

3,6 o  D6E  ( ( ak an! 6 i e  %


3   p  ( e i' 6
 3:o 6 
!s
! ep 
! : (o 
! )
' o
! ep 
! 
(o
! )
   23 i, OOP e   
;
3 u A  6 , 3 % ak
an! ei'
!  6 6s6 p
!
ii e %!  , ,
% e  e e i
;,% 3 u
 ei'
p k  p  as  e %   e  ' 
, : u   %  n e   s  'n 6 ,
p k  %  ak
nd  %  @  6
%6 ,e ak
!
p k
!    %(    !  g  %k!  g  %   2 A
 o ( ,  
p6A ak pn     k %k
ei  k( 6
 ! e properties e 6  D6E 
a  e
 ,   ak( @ m
 7 6 (parent-child/base-derived)
4.

 u KT   sT   u   ( MVC St r uct ur e Tut or i al i n


Bangl a)


 :


o  %

! u n   s '   MVC Structure (e


! ! i     d6) %  %( ei'6 ep 
D6E  ' 6 
!
 ,6
01.<?php
02.include "common-libs.php";
03.include "config.php";
04.mysql_connect($hostname, $username, $password);
05.mysql_select_db($database);
06.?>
07.<?php include "header.php"; ?>
08.<h1>Home Page</h1>
09.<?php
10.$sql = "SELECT * FROM news";
11.$result = mysql_query($sql);
12.?>
13.<table>
14.<?php
15.while ($row = mysql_fetch_assoc($result)) {
16.?>
17.<tr>
18.<td><?php echo $row['date_created']; ?></td>
19.<td><?php echo $row['title']; ?></td>
20.</tr>
21.<?php
22.}
23.?>
24.</table>
25.<?php include "footer.php"; ?>

e 
!  6s6 ei
! m :   %!  i6 :
 R , 3  a  am! u n  
! i    ei    @   e2ei MVC Structure
!( 3  (  ( 
  @
:  n 
e   i 
3 e  
!(  ,ei  ( 3A ,
! (Model)
u (View)
n   (Controller)

 ( MODEL) :
@ %
!i( i 
!   e  ep  D6E 62,ei ep  
!( @ ! a @ t p

!( (a  6    (   () 


3 !( d  %
! 
! i ,!,%! i6 :
a  n ! a % 
! s '  pn ei  (  ,   (business logic)
u ( VI EW) :

e  p s
!( 
3( d  iu  e 

:a  n e e   @  o
  6   ei'Aee

 !i( i  e  e 
 e  ao 6  
3

,! ,  ,%ee
 i  :
KT   ( CONTROLLER) :
n   p s
!(  3  d  ! e u e  ( e a  
3 ( 3 ( a  n ! e u
    ei  ( e 
 , 

!i( i 
Oo MVC a  n ! u n   s '  e t   a  n e  e 
!
 ,


5.

0 ia4 i   u4  e 2 i4s ( CodeI gni t er Downl oad & I nst al l


Tut or i al i n Bangl a)


 :


o$  %

p  http://codeigniter.com/downloads/e 

!i( i 
Oo$ A ! u ! , eA .zip format e
 e %  e %  o$    % ! ,
3,6 %
  6 
: c 6 i e     ,c
htdocs folder,eA   ei
   F:\Program Files\xampp\htdocs. eA C Drive e  %  6 C

drive e   F :$2 6 i F
: c%  6
: ei
   C:\Program Files\xampp\htdocs. e  e
! u ! b 6 (e % b 6)
 l A % ! a  n  
s  % @
 l A   :  CodeIgniter.
e
!i( i 
 l A  e system>>application>> config>>config.php  iA m k   e!

view source
print?
01.|------------------------------------------------------------------------02.| Base Site URL
03.|------------------------------------------------------------------------04.
05.
06.$config['base_url'] = "http://localhost/CodeIgniter/";
07.
08.
09.
10.
11.|------------------------------------------------------------------------12.| Index File
13.|------------------------------------------------------------------------14.
15.
16.$config['index_page'] = "index.php";
17.
18.
19.
20.
21.|------------------------------------------------------------------------22.| Default Language
23.|------------------------------------------------------------------------24.
25.
26.$config['language'] = "english";
27.
28.
29.
30.
31.|------------------------------------------------------------------------32.| Default Character Set
33.|------------------------------------------------------------------------34.
35.

36.$config['charset'] = "UTF-8";
37.
38.
39.
40.
41.|------------------------------------------------------------------------42.| Cache Directory Path
43.|------------------------------------------------------------------------44.
45.
46.$config['cache_path'] = 'http://127.0.0.1/codeigniter/cache/';
47.
48.
49.
50.
51.|------------------------------------------------------------------------52.| Session Variables
53.|------------------------------------------------------------------------54.
55.
56.$config['sess_cookie_name'] = 'ci_session';
57.$config['sess_expiration'] = 7200;
58.$config['sess_encrypt_cookie'] = FALSE;
59.$config['sess_use_database'] = FALSE;
60.$config['sess_table_name'] = 'ci_sessions';
61.$config['sess_match_ip'] = FALSE;
62.$config['sess_match_useragent'] = TRUE;
63.$config['sess_time_to_update'] = 300;
64.
65.
66.
67.
68.|------------------------------------------------------------------------69.| Global XSS Filtering
70.|------------------------------------------------------------------------71.
72.
73.$config['global_xss_filtering'] = FALSE;
74.
75.
76.
77.
78.|------------------------------------------------------------------------79.| Output Compression

80.|------------------------------------------------------------------------81.
82.
83.$config['compress_output'] = TRUE;
84.
85.
86.
87.
88.|------------------------------------------------------------------------89.| Rewrite PHP Short Tags
90.|------------------------------------------------------------------------91.
92.
93.$config['rewrite_short_tags'] = FALSE;

6.

0 ia4 i  41a   ( CodeI gni t er Conf i gur e Tut or i al i n


Bangl a)


 :


o$  %

e 
3  config.php  iA 2 o  database.php   e   i %2
A
3  e!  e ' 6
(  
01.$active_group = "default";
02.$active_record = TRUE;
03.
04.
05.$db['default']['hostname']
06.$db['default']['username']
07.$db['default']['password']
08.$db['default']['database']
09.$db['default']['dbdriver']
10.$db['default']['dbprefix']
11.$db['default']['pconnect']
12.$db['default']['db_debug']
13.$db['default']['cache_on']
14.$db['default']['cachedir']
15.$db['default']['char_set']
16.$db['default']['dbcollat']

=
=
=
=
=
=
=
=
=
=
=
=

"localhost";
"root";
"mypassword";
"mydatabase";
"mysql";
"";
TRUE;
TRUE;
FALSE;
"";
"utf8";
"utf8_general_ci";

e  address bar e http://localhost/CodeIgniter/  en  : ' 6 % a  n   is


; ,

7.

0 ia4 i  e pg ep 34 ijk ( Cr eat i ng Fi r st Appl i cat i on wi t h


CodeI gni t er )


 :


o$  %

@ c % ei Au   u  %( OOP e OOPHP e Au  (  e2 6  , e 76
  ak an!
p g  e  
!i( i  e  a %2 %( Au  (  % 6 o 76
 ,6  p  R %2

!i( i  MVC Structure e t 


!
  @
:,e6  o ep  D6E   , , 3  
ei d6   (! a
!(),ep   ( n   a
!()e    (u a

!()  % : % :   3 i
, e ep  D6E $e 
2  ep  D6E 
: cei ep  @
n   e u e ,   ,e 

! 
i 6 i ! eo
i
F:\Program Files\xampp\htdocs\CodeIgniter\system\application\controllers ei
   ($ e 
helloworld.php    i D6E (F e $( $ C , % ) ei  iA
 e! 
3
  !++ e
 e  class D6E  e ' 6 
01.<?php
02.class HelloWorld extends Controller{
03.function HelloWorld(){
04.// load controller parent
05.parent::Controller();

06.}
07.function index(){
08.$data['title']='My first application created with Code Igniter';
09.$data['message']='Hello world!';
10.// load 'helloworld' view
11.$this->load->view('helloworld',$data);
12.}
13.}
14.?>

  : n   a
: e  6  k  D6E  ,2 e ,c  k /p6 :6 k / k 
3  k  'Controller'


  ,2ei 'Controller' k A
!i( i  %(
 i D6E 
2 e ,c
 k / n k ei  n
k  'Controller'
 extends  o !A :  k  'HellowWorld'
  ,2  6   p6 :  ,2
(derived).
e parent::Controller() e function index() d  ei'
 ,c 6   n k  (Controller e) 3 o
e index()
 ! ( ) 
 6  p 6  2
! i  ,2 $data
 (a ) e d6E6 u

p ei
! n   ,2
3i
mp    'helloworld.php' loader   e  k 
%2, n   e  6  k  D6E i ei loader k  a A 6     i !l ' %e
!i( i  ei
loader k A  ,   u  iA
 !    ! 6 , e 
$this->load->view('helloworld',$data);
e c u  iA
 !  e
! ( e  pass 
:
3 b u 
: u  iA D6E  e 
F:\Program Files\xampp\htdocs\CodeIgniter\system\application\views ei ($ helloworld.php
  e   i D6E  iA  
1.<html>
2.<head>
3.<title><?php echo $title;?></title>
4.</head>
5.<body>
6.<h1><?php echo $message?></h1>
7.</body>
8.</html>

e Address bar e  e en  :


http://localhost/CodeIgniter/index.php/helloworld
A: Controller e Views folder e 3 k welcome.php e welcome_message.php  i:A

  !++ e 


: a  2 6  

You might also like