PDF Archive

Easily share your PDF documents with your contacts, on the Web and Social Networks.

Send a file File manager PDF Toolbox Search Help Contact



5. PHP bangla tutorial php basic .pdf



Original filename: 5. PHP bangla tutorial php basic.pdf
Title: 5. PHP bangla tutorial php basic.docx
Author: Hridoy

This PDF 1.6 document has been generated by PDFCreator Version 0.9.8 / GPL Ghostscript 8.64, and has been sent on pdf-archive.com on 04/01/2015 at 11:57, from IP address 114.130.x.x. The current document download page has been viewed 13769 times.
File size: 644 KB (67 pages).
Privacy: public file




Download original PDF file









Document preview


ei

A. ei

1.

i s

2.

3. Syntax
4.
(Variables)
5. s (String)
6. a (Operators)
7. n
s n
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 0 i 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 0P o R






1. ei 0P o R u | ( PHP Fr amewor k Tut or i al i n Bangl a)
2.a яk a K 0p g 2 e 2 ei ( OOP & PHP Tut or i al i n Bangl a)
[ \ a яk a K 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 4 1a ( 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 e p 34 ij k ( 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! sk p m e я :
% sk p , 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 sk p ( $я। ei' e

( syntax ( C,Perl,Java
@ ।ei ( $яA u d , o $
я d6 D6 E ! i ।
ei' (PHP)
% ( я : :
:
1.HTML . ; HTML Form.
2. C я 6 , @ % 2।
3.я skp
1 o p я4 ?:

3 o $ ei'
hosting(я $( ) 6 , ।e я ( 6 , ।e ;$A $ s 6

% ' , ।
% 66
я % я mu i o $ i s
।e я m k o$ ( i s 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 i s
:$ 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 i4s 34 ( PHP I nst al l at i on Tut or i al i n Bangl a)


:


яo$ %

p Au $ A
6 N 2 6 , e 7 6 % , ।k in o$ ( 6 % 2i e @ i s : 6 ,
o $
3 apache e a i ei' % e
! o$ o i s : $
3 :MySQL, я (
6 2।e o$ ( O o$ 3 $। P$ e6k ( ( ' : $ o$ (
я 2 ।e ,я R
: c e e e o$
3 i s : ( e i i s , $ 3 ।% % : % : i s : 6
, । o$ A
, c
XAMPP.XAMPP
e


! u !

i s

http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe a o$ e 6 i s
: ।
in
;
!s XAMPP e e A %i
:
! k o a a 6 -
3 U i
i s : $ 2

( i e XAMPP Control Panel %i
: 6 a n % 3 : C U i i s
:
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 i s mn , $ 2 a n % mu A e , я
2(
)

3.

ei 0 0 g o 4 ( PHP Code Wr i t t i ng)


:


яo %

q r 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 !k n ! i k , c “C:\xampp\htdocs”(6 3 : a U i i s :
3 :D drive 6
e , “D:\xampp\htdocs”). e 3 : ei ! i k 6 “mytest.php”
i 6 , % e 6
a
6 e -b uя e U 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 c n @
, ।

4.

ei 0 2 j u ( PHP Synt ax Tut or i al i n Bangl a)


:


яo$ %

ei'
!
я 6 a i i extension .php 6 , ।3 : .html 6 , ei'
! execute
, ।
* ei'
! e p 6A a <?php 'h : $ e ?> 'h : $
; , ।
* e ei' Scripting Block(<?php e ?> e 6 3
,$
$ e b ) !k n 6 6

*p 6A % : 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я e U http://localhost/mypage.php e en : ' 6 %u
: 6 ।

ei' e %u я : A
s n ^6 ,$ echo o print.
ei' n: $
'h % 2 3 :
ei'
! e( : $ 6 , e
!( % execute , ।6
n

!( e ! , a m $ 3 :
6 , e n
: 7 6 % 6
' $ 2 ।e
i n 6 ' i // # % , i n 6 ' i
! % ( /* e
; */ 'h , 6
, ।
: a p A ,
3 k 2
ki। 3 <?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

6। ei'
6
“$” ei 'hA : $ a i 6 , , я ।
*
case sensitive.
3 $a_number and $A_number : A % :
, ei' e :b c 6।
* 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 (@ ) u l o
ei' я


R
! i n


d 6:
1.a i
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 ( t g g ।6 i e h @
% ।

s , % ( e D6 E 6 , ।e s e , , 6 a e $ store
6 । '
: e i s : D6 E 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 i।e я $ 6 ,
3 3 i
s
% e @ , p @ 6 i
e
$ i $ store ।
%c e u
! k
।b uя ' 6 %u ।

e6k 6 Double quotes d s D6 E , $ 2 e Single quotes d s D6 E 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 , e 6 2 @ % 2
3 single quotes e i।
ei'

3 d 6: A % ' , e : A @ 6
p g ( $я e
k t ^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 я a i
$ 6 , *<<< 2 identifier % 2 3 % , 6 , heredoc % (
3 % TEST , 2।
*
;o eA , 2 e
k : $
; , ।
*e яi e i , ,(indent)
i A 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
k E d 6
3 -Arithmetic, Assignment, Comparison
Operator etc.
a
i4 K 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
: -

j9 4 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 (
k t।% 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 ।
%
k t @ “-” a ^6 , ।

8.

ei K 34 0s K ( PHP Condi t i onal St at ement )


:


яo$ %


6 u
action
$ я n
s n ^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.<?php
2.$d=date("D");
3.if ($d=="Sat")
4.echo "Have a nice Day";
5.?>

* 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 $ % s i , 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 F…ELSEI
F ELSEI F…ELSE
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 b t я $ 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 e N $ 3 $।3
; b A % 6 condition %
'
,true ,
! % execute ।condition e 36
:$ % 2 66 e ' i। 3 :
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 p 6 1

N । !A %u % e The
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 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 , $ 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 b t % (i e e execution ,$।2$ A Boolean
expression
3 p 6 g b t % (i e e s6(evaluate),$,ei true , g b t ' % false
return 6 , g b t 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 A 6 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 p 6 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 @ (> d 6 , c 2 u : k (series of
element) 3 u : ( index 0
, k u 6 । a
3 ' ,яA , c1.<?php
2.$city=array(“Dhaka”, “Chittagong”, “Rajshahi”, Sylet”, “Khulna”,
“Barishal”, “Barishal”);
3.?>

e variable e , store ,
( 2,p 6A , e e A u : e p 6A u : e A index
:c , ( 2।array’ 1 u : e index/key , c 0 6 , e Dhaka[0],Chittagong[1]… e
( ।e %
3 u : e index number u l
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)
e6k 6 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 i 434 a
( MULTI DI MENSI ONAL ARRAY)
ARRAY)
e e a 6 p 6A u : e A a , 6 % ei a p 6A 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 9 2

FOREACH LOOP
@ e A associative array % 2 e % g b t 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 i c 6 execution 6
।e ei' e g k 6 ।p 700 e o
l i % 2 ei'
6।
e 3 , 6 i 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 23 4
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 1 R u ( PHP For m)


:


яo$ %

e6k ei' ’ 36 2
, e 6 p $ ( $ e 2। 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'Ae e
: , 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
!A 6 method=POST
:$ % 2,Form e
! ei'
6 6 : A d 6

, ,$ POST e GET.
welcome.php i A , e
1.Welcome <?php echo $_POST["fname"]; ?>!<br />
2.You are <?php echo $_POST["age"]; ?> years old.

e @ % A 6 я $( $ : rezwan e age : 24,e k %u e
Welcome
rezwan!
You are 24 years old.

15.

ei $_GET
$_GET 0 g ( PHP $_GET Met hod)


:


яo$ %

6 GET
! e > 6 b uя e U 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я e U ' 6
:
http://www.w3schools.com/welcome.php?fname=Peter&age=37
welcome.php i A e $_GET Method ,
! g, ।
1.Welcome <?php echo $_GET["fname"]; ?>.<br />
2.You are <?php echo $_GET["age"]; ?> years old!

16.

ei 0 s 0 g u ( PHP $_POST Met hod)


:


яo$ %

ei d 6 6
3 6 i >
, 6
u
: 6 b uя e U 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я e U ' 6
:
http://www.w3schools.com/welcome.php
% e
! $_POST Method d 6 6 (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 :
k t 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 ' i 6 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$ %

% i c i e k u % (i ei' e e i a a % ei' i i $ : 6
include() : $।
Require()- , fatal error(( 6 )
: e skpA e k u n : ।
Include()- , 6 : e skpA e k u
e : A : $ a я
' 3 $
3 % 3 : e
,
,! ,
3 a
3 % '
3 % o $ i

яi e
: 6 , e ei' i
(
,
,! , i6 :) D6 E a
я e : A : $
3 (
: 6 । % : % : p 6A
я % e(
3 ( 6 , ।% 3 : ei include i
2 % !

e
6 я
3 ( 6 ,

я ( $i 3 k , । b
я ( $ %
3 ( 6
, ।u: , ,@ “menu.php” e i aa 2 ' 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 e k 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.txt”a n ei i A e d6E A “r” e e

3 : R
: 3 i A
a s (
!) 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 i A 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 ।

% i c 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 ( i A
, ।
u u: , “upload” e
l ( i A
, ।

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 a k %
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 ij k j t
setcookie() function e ^6 , k D6 E 6।
setcookie() function A a i <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 D6 E
3 iuя ; o iA visit 2
i 6 k 3 6
e :
6 e я iuя 6 a a % i % ।% ' i k
: R : 6

3 % e
: 30 : : 2।a 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 e o iuя 6 % 2 ,3 :
6 , iuя ; visit 2 6
: 3 ।
k 9 v 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
e p я ,
, n
6 n e e
6। mu
7
%
।% я 2 ,
; 2 e 6 6 2 । n in e , -o
7 6 %
% 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'
p 6A iuя я a ' unique id (UID) D6 E ।
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
2 k4
2 k4

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
: я ) D6 E я ।eA я isset() A
, , ।ei A
'
: ‘views’ % (
i
% 2 ।3 : ‘views’ variable

6 , % a : counter u 6 ।% 3 : 6 , ‘views’variable D6 E 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 e 6

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 e p D6 E 6 error handling e e A ( t g ।3 : e
( )
'
!
a 6 6 , %
p g A %
, e t я 6 7 ।
ei Au e
' e 2 p' 6 d 6 % ' , । 3
"die()" statements
Custom errors and error triggers
Error reporting
"DIE()"
DIE()" 0s K
t e h K
e e
2
!
3
kk i ।
1.<?php
2.$file=fopen("welcome.txt","r");
3.?>

3 : i A
a s6i 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 : i A 6 , ei
я
: ।
File not found

to

open

stream:

ei
!A u
!
' e n।e e @ d 6 e 6 error , skp n , 3 ।6 e d 6 ,
a R ।
s e h K
h K ij k
e % @ e ei' D6 E
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 ।a i e

value number 6 , । '
m error report level
: , ।
error_message

% । iuя b 6 я error message :c ।

error_file

p c । p i A u l
3 , 2।

error_line

p c । p i A u l
3 , 2।

error_context

p c ।e a u l (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. sk p 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 ij k 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 ।% i c e 6 я 6 error handler : 6
PHP
6। ' u: ,
: ei я D6 E error handler , 6 ,
set_error_handler("customError");

3 ,6 error handle я % я D6 E , 6 ' i,6 i set_error_handler() e e
: ,2 %
3 (
3 6 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
sk p
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 % я
D6 E 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

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।
i i 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

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 e p e i ( t g । ( o e p i i u
।% 3
o e p D6 E 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 a 6 k 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 a i 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 a st % 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 (i i ) % 2 3 "GET" method , > , 2।
1.
' i e "email"
3 GET
! , > , 2
a st % 2 ।
2.3 : i e a st 6 ,
' e R i i e U ।
SANI TI ZE I NPUT
p P6 , 6 ,
3 i b 6
!
3 % я 2 6 a st % 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
a st % 2 ।
2.3 : i e a st 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 \ i4 9 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 0 i 1 234 ( PHP Mai l Funct i on Tut or i al i n Bangl a)


:
яo %

% PHP mail() d o
я
i i > 6 ।
6
1.mail(to,subject,message,headers,parameters)





to

я । e
3 i i R
i R
i 3 ।

subject

я । e ; u l ।

message

я । e
я 3 > , ।
я i ( (\n) 'h d b , e
i 70 ak

headers

p c । e d a 6 k
3 ( 3 ।
3 :From,Cc,Bcc.

parameters

p c । a 6 k
3 ( 3 ।


:
i 3 я % s i i i s 6 , e php.ini i A
i a 3 E (
6 , >> 7 6 , 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 p 6A Au n s % 2 % % ' c
3 n (
%
i R ' % 3 6 7 6 % Au A 6я 2
( 2।a 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 i i e a A 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
: i i e a A 2 6
i
R
: ।
:
:e 4 r d j 4 e j ei 1 R
t a \ iuя 0 i r j
e i i i4 я 34।i i i4 я 34 0g u t form validation.
validation.q PHP
1l (Filter)
Filter) a2 3 u 4R4 v

C. ei
ei 0P o R
1.

ei 0P o R u
u | ( PHP Fr amewor k Tut or i al i n
Bangl a)


:


яo$ %



ei'
O o$ (PHP Framework) , c e basic Platform/structure((> )
3 o $ a p
D6 E 6 ^6 ,$।



( d 6,
like k
: ei
s A 6я 2n (like) 2,p 6
я 6
!
, j e 6 i6 : e( e e A e p e u: , ।



PHP Framework , % e p D6 E
3 @ ( -p' $ ' ,
! D6 E
7
k,d6 a p D6 E 6 ।



e2 N
! 3 ( e Ao ,я
6 ,e( 2 N o % o a @ % 2 , я i 7 6


,я $ ei'
O o$ (PHP Framework) e e A o$
3 i s : % , яi e o $ i
D6 E 6 e % (
i a
! D6 E ।
ei'
O o$ (PHP Framework)
% (
3 ;$( я 6 ,
1.PHP( ; PHP Function, Variable etc)
2.Object Oriented Programming
3.MVC(Model View Controller)Structure
a ei'
O o % 2
3
яn
O o ,
, , ,
!i( i i6 :। яn e
!i( i '

я p 6
яn e я

R -
яn : en p iя ei' e я 3 ।6 i p i o


O o : я
u 'n
3
!i( i ,
, i6 :।e %
!i( i (CodeIgniter PHP
Framework) e u 2
~ @
:$
'c ।

2.

a яk a K 0p g 2 e 2 ei ( OOP & PHP Tut or i al i n Bangl a)


:
яo


яo %

p u a K 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
'6।e u
p g e
2
2 a ( , ,p 6A a i e
p g e e +
! ।
, e u
p g
n
! я
n , 2 e
c e
p g i % u 6
, ।3 i , % 2 % 2 POP
6
3 a @ 6
global data %k n ,
3 6

6 e % o % 2।
a яk a K 0p g 2
0p g 2g 2- OOP( OBJECT ORI ENTED PROGRAMMI NG)
NG)
OOP a яk a n!
p g (Object Oriented Programming) ei ( @ 2 k E @
e 2।OOP
! critical element , ' e s
! k p , (free flow) n
: ।OOP
e e @ Objects (R6,e @ я ei a яk( 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)
a яk D6 E , 2
! e
! ,ei
!
! ( ' ) ।a яk , c e
( 2 6
(a bundle) 3
! e n D6 E।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 a n! ei'
6 %
3 ! (
: % e( 2 a яk e
( 2 /
/
6 u (bunch).e g
@ я ei a яk( e t я ।e u: , , 6 e
s n ( ei' skpA),
3 % 2 e ( c
e (bunch) ' E (a яk( ),6
s n e я ,
3 p 6 ' E (a яk) я я я
‰ m : s6nt ।
k ei' ( d 6-Procrdure Oriented way) e 3 : 6 6 ,
:


(bunch) sk pi 2u ' ' ।
k ( CLASS)
ei'


6

a яk

D6 E

% (

%

ei

a яk

e

я

e

/e

l

(blueprint/template/outline)D6 E 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 a n! ei'
! 6 ei' e living,breathing a яk D6 E k e u t
।living,breathing a яk 6 7 , c ei a яk A
6 D6 E , ।
e4
s 34 ( ENCAPSULATI ON)
e k (class) e @
! e i e ।e k e A k E D c ।e 6 k
6
! 6 i
e o 3 ।a n i
ei
! 6 p 6 । @ t 3 : ei k
6 i
6 ,
i Ai @ ei
! 6 e 6 । i

! ei e n ,
3 o p k
! 6 (data hiding/information hiding)
i4 t n ( I NHERI TANCE)
OOP
6 i , n
! g : , (reusability) @ p: ।a n e k a 6 k 2
3 (
3 6
k A : 2 u i।@ % sk p e k % 2 e % % 6 k D6 E 6 ei k a@E ।
k A , k
k (super class/base class)%
3 k ( e

,
(
k /p 6 :6 k (subclass/derived class).extends ei o !A :
k
e A 6 k
3 ।
1я ( POLYMORPHI SM)
e @ a яk e я e i , 3 n я , 6 ei p k я ।
0 я a jk 4 ( 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 p k i ,
я a 6k ।

3.

‘[ \ a яk a K 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) ' 2। ei' 5 mg a яk a n!।e % ( ei' 4 mg a яk
a n! 2 । ei' 5 a яk a n! ,o 6 e : яA , , 3 ( , ! o e p D6 E ,я ,

( 2।OOPHP
! D6 E % ( % ei' ,
, n
s n, i6 : @ 6 , ।
Au A ,я e D@3 @ 6
23 A
2
2 a (@ ) ( , 2।
\ \ - ^:
pg ‘ ei 0 я ij k r4
index.php
class_lib.php
% : a яk a n!
! e i
i i A % ei' ‘includes’ , ei'
e
я i
: ।ei Au я % : a яk a n!
! class_lib.php i ।OOP
% k D6 E A я u6।k , c
m p /k a яk e я 3 p a яk m @
: ।
\ \ - ‘:
e ei k ij k
ei' sk p ,
!,
i6 : 2 u 2A 6 3 % a яk a n! d 6 6
! 6
p i e k D6 E 6 , ।k D6 E я p i ‘class’ bA : 6 , e e k i c 6 : 6 ।
1.<?php
2.class people{
3.
4.}
5.?>

\ \ - [:
k 0 0q a
k , c a я k я b pn/ ।3 k 6 % e
D6 E 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/0 g 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 /
! D6 E 2 get_name() e set_name() ei ( я e A E 6
' 6 ,
e k getter e setter a i 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 2।e 6 3
ei'
p g
% a яk я 6
3i t
% set_name() /
!
: 6
7

3 e
a i e property/variable 3 , ‘name’
\ \ - •:
‘$t
$t hi s’
s 0

! m 6 ' i A
: 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;
}

7 6 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 a n!
p g e u d i , । ' , k
% : e ei'
я D6 E 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 e o k : 2 ,e , ।
\ \ - ˜:
a яk ij k
e k a яk D6 E p k instantiation.
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
</body>
</html>

$rejoan
6 D6 E people a яk e я
n।% $rejoan , ei people
a яk nt e , я ।

\ \ - ™:
new o R
e k 6 a яk D6 E 6 % ei new o !A p я , ।
% i c e k a a яk D6 E 6 । ei' i ‹я 2 p 6A a яk % : % : (s6nt
st )
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
$riad = new people;
</body>
</html>

a яk D6 E k @ quote : 6 , , ।a n ' e
$rejoan= new 'people';

\ \ - ^š:
a яk properties ‹ (set)
set) ।
% : A a яk D6 E 2 people ,e % 6 : properties R (set) : 6 p

!A(the setters) ,
3 % ( D6 E ।
e 6 ,
3 3 :o % : a яk e 2A($rejoan e $riad) e i k people e u t
D6 E , 2। ei' n 6 : mg % : , ' a n ei' e 2A a яk
: 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 , a я k
! 6 e 6।e ,
i
! 3 % setter
! :
a я k 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 ।

a n % ei Au a @
;

3 3 :
e ei' k !я i
ei k u t e я u a яk D6 E
a я k
! i


Related documents


PDF Document devry comp 220 ilab 3 bank
PDF Document sheet 1 2015
PDF Document comp 220 ilab 2 resistor lab report and source code
PDF Document devry comp 122 lab 6 lab report and source code
PDF Document comp 220 ilab 3 bank account lab report and source code
PDF Document devry comp 122 lab 7 lab report and source code


Related keywords