SlideShare a Scribd company logo
eieieiei
AAAA.... eieieiei
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
BBBB....a n eia n eia n eia n ei
• 1111....a n ei ua n ei ua n ei ua n ei u |||| ( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)
• 2222.... ei uei uei uei u ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)
• 3333.... ei i k uei i k uei i k uei i k u ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)
• 4444.... eieieiei ( PHP r eq( PHP r eq( PHP r eq( PHP r equi r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)
• 5555.... ei i uei i uei i uei i u ( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)
• 6666.... ei i uei i uei i uei i u ( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a) 7777.... ei kei kei kei k
uuuu ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)
• 8888.... ei uei uei uei u ( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)
• 9999.... ei e h uei e h uei e h uei e h u ( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)
• 10.10.10.10. eieieiei iiii ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)
• 11111111.... ei l uei l uei l uei l u ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)
CCCC.... ei oei oei oei o
• 1111.... ei o uei o uei o uei o u |||| ( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)
• 2222....a яk a p g e eia яk a p g e eia яk a p g e eia яk a p g e ei ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)
• a яka яka яka яk aaaa eieieiei ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)
• :::: ---- |||||||| ::::6666---- 10101010 |||||||| : 11: 11: 11: 11---- 15 | |15 | |15 | |15 | | : 16: 16: 16: 16---- 23232323
• 4444.... i i u e i si i u e i si i u e i si i u e i s ( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
• 5. u T sT uu T sT uu T sT uu T sT u ( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)
• 6666.... i ii ii ii i ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)
• 7777.... i ii ii ii i e p e pe p e pe p e pe p e p ( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )
AAAA.... eieieiei
1.1.1.1.
ei uei uei uei u |||| ( PHP Basi c)( PHP Basi c)( PHP Basi c)( PHP Basi c)
: яoяoяoяo
ei e i sk p m e я :
sk p c p g b e c instruction e run s k я
।“ iiii ” c ei skp iuя mu nt handle
u ei o я я o ei Process :
(Picture,Content etc) (math calculation,file operation etc) e
HTML e n iuя o b uя ।
eieieiei (PHP) ?:
PHP Hypertext Preprocessor e i ,k p ,HTML-embedded sk p я ei e
syntax C,Perl,Java ei я u d o я d i ।
eieieiei (PHP) яяяя :
1.HTML . HTML Form.
2. C я ।
3.я skp
o p яo p яo p яo p я ?:?:?:?:
o ei hosting(я ) e я e s
।
я я mu i o i s e я m k o i s
mu -
* oooo
1.e PHP -compitable o : apache
2.PHP
*k ink ink ink in oooo
1.o b uя я k(e i s i )
2.e k e : ei e я Specialized e o s ।
webcoachbd.com eeee uuuu eieieiei ।।।।
2.
ei i sei i sei i sei i s ( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)
: яoяoяoяo
p u e k in o i e i s
o apache e a i ei e o o i s :MySQL, я
e o o e k o я e я
c e e e o i s e i i s i s
o c XAMPP.XAMPP e u i s
http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe a o e i s
।
in s XAMPP e e i k o a a - i
i s i e XAMPP Control Panel i a C i i s
C:Program Filesxampp C:xampp ei e start click (Apache
e MySql)।
Apache o MySql b uя e http://localhost e я
English k ।
ei я i s mn a mu e я
( )
3.
eieieiei ( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)
: яoяoяoяo
C driveC driveC driveC drive eeee XAMPPXAMPPXAMPPXAMPP i s ei li s ei li s ei li s ei l htdocshtdocshtdocshtdocs llll
web contentweb contentweb contentweb content g ।g ।g ।g ।
www k n i k c “C:xampphtdocs”( a i i s :D drive
e “D:xampphtdocs”). e ei i k “mytest.php” i e
a e -b uя e http://localhost/mytest.php
c e , e ? ? ei я
s iя o : Net Beans, Dreamweaver i e a e
i , e IDE (Integrated Development
Environment). c n ।
4.
eieieiei uuuu ( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)
: яoяoяoяo
ei я a i i extension .php .html ei execute
।
* ei e p a <?php h e ?> h ।
* e ei Scripting Block(<?php e ?> e e b ) k n
।
*p instruction(code line) k d ।
o e e ( / ) e
<?php
echo"This is my first php page";
?>
e я mypage.php , htdocs browse save in e я e
b uя e http://localhost/mypage.php e en u ।
ei e u я s n echo o print.
ei nnnn: h ei e e execute
e , a m e n e
i n i // # i n i /* e */ h
।
: a p , k ki <?php e ?>
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
e k ।
<?php
echo "Hello World!";
echo "Hello World!";
?>
ei s я ,e p я ।
5.
ei uei uei uei u ( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)
: яoяoяoяo
c e t (Container) a e kk String “Hello
Bangladesh” a e integer value 100. e e e ( e e
declare ) я , (value)
ei “$” ei h a i я ।
* case sensitive. $a_number and $A_number , ei e ।
* m k ei
$variable_name = Value;
u i -
1.<?php
2.$hello = "Hello World!";
3.$a_number = 4;
4.$anotherNumber = 8;
5.?>
* ei e “Loosely Typed” я i declare e i ( ) u l o
ei я i n ।
d :
1.a i letter or “_”(under score) ।
2. alpha-numeric characters o underscores. a-z, A-Z, 0-9, or _ . ।
3. s e a “___”underscore ($my_string) a
ak ($myString) ।
6.
ei sT uei sT uei sT uei sT u ( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)
: яoяoяoяo
ei s e k o । ei Career e ei s e t i e
।
s e e s e a e store
e i s ,e store echo ।
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 d s echo ,
store i e я i s e p i
e store ।
c e u k b uя u ।
e k Double quotes d s e Single quotes d s e i ,
o apostrophes ।
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.?>
s e single quotes e -
echo ‘PHP it’s neat’
e double quotes e single quotes e i।
ei d e p g я e k t , n ei e
o i s quotation i heredoc,e
s e -
1.<?php
2.$my_string = <<<TEST
3.He will be succeeded here
4.and here after!
5.TEST;
6.echo $my_string;
7.?>
e s я a i -
*<<< identifier heredoc TEST ।
* o e e k ।
*e яi e i ,(indent) i ।
u <br>( i b я ) s e ।
7.
ei a uei a uei a uei a u ( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s)
: яoяoяoяo
a - manipulate 3 a
1.Unary – e (operand) я ।
2.Binary- ।
3.Ternary- 3 ।
e Operator a d -Arithmetic, Assignment, Comparison
Operator etc.
a i aa i aa i aa i a ( ASSI GNMENT OPERAT( ASSI GNMENT OPERAT( ASSI GNMENT OPERAT( ASSI GNMENT OPERATOR)OR)OR)OR)
e aaaa e a e ।
$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 -
aaaa ( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR))))
ei Operator e relationship ei Operator n statement e
statement true false.
e 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
sT asT asT asT a ( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR)
e i o -“”, ‘’
ARI THMETI CARI THMETI CARI THMETI CARI THMETI C eeee ASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATOR e COMBI NATI ONe COMBI NATI ONe COMBI NATI ONe COMBI NATI ON
Programming e e я c e , k t 1 i
$counter=$counter+1;
k e
$counter+=1;
Pre/Post-Increment eeee Pre/Post-Decrement:
u e ad ,e 1
$x++ $x += 1; a $x = $x + 1 e ।
k t “-” a ।
8.
ei sei sei sei s ( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )
: яoяoяoяo
u action я n s n o i e e feature
i u i 12 “Good Morning” u 5
“Good evening” ei e o я o a n я Conditional
statement e ,condition e u t ei s k я i ।
ei Conditional statement -
*if statement
*if…else statement
*if…elseif…else statement
*Switch statement
* I F STATEMENT* I F STATEMENT* I F STATEMENT* I F STATEMENT
if statement execute condition true u u
Have a nice day Saturday ।
1.<?php
2.$d=date("D");
3.if ($d=="Sat")
4.echo "Have a nice Day";
5.?>
* I F* I F* I F* I F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT
c o e , , i e i if…else statement
e u e 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 true a Saturday u
Have a nice day Today is not Saturday.
* I F* I F* I F* I F…ELSEI FELSEI FELSEI FELSEI F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT
ei statement d e e b execute ।
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 uei uei uei u ( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)
: яoяoяoяo
e я i e i 50 i e e i 100
я i p g e я c e n i ei t я i i
e ।
c e e statement e b execute k я
।
4 -
While Loop
Do…while Loop
For Loop
Foreach Loop
10.
eieieiei WhileWhileWhileWhile
: яoяoяoяo
e condition true while e b execute ।
1.while (condition)
2.{
3.code to be executed;
4.}
condition false b e b condition
,true execute condition e e i :
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 k k I e 5 p 1
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 ? i e while loop e i execute
।
DODODODO…WHI LE LOOPWHI LE LOOPWHI LE LOOPWHI LE LOOP
e while loop e i e k condition test , , while
e a k e execute i।
1.Do
2.{
3.Code to be executed
4.}
5.While(condition);
u o u 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 i=6 i ?
This is line 6
This line is outside while loop.so it will not repeat.
p i e execute p execution e repeat
? n while loop e p i ei ।
11.
ei uei uei uei u ( PHP For Loop)( PHP For Loop)( PHP For Loop)( PHP For Loop)
: яoяoяoяo
ei e я e я while o , e ।
1.for (init; condition; increment)
2.{
3.code to be executed;
4.}
for loop statement b 3 expression k d k 1 assignment
statement(loop control variable),p t i e e execution 2 Boolean
expression p t i e e (evaluate) ,ei true t false
return t n 3 loop control variable e
u i=1 e e k I e 5 e I e 1 ।
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
expression e e expression , d k Boolean
expression e default true ei u u 1-10 ।
foreach loop e array e i
12.
ei a uei a uei a uei a u ( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)
: яoяoяoяo
e e single value e t(container). n a e value’ container t e a
u p u value -key index u ।
s e e single variable e store e
-
$city1= “Dhaka”
$city2= “Chittagong”
$city3= “Rajshahi”
$city4= “Sylet”
$city5= “Khulna”
$city6= “Barishal”
n e a e e e a d c u k (series of
element) u index 0 k a я c-
1.<?php
2.$city=array(“Dhaka”, “Chittagong”, “Rajshahi”, Sylet”, “Khulna”,
“Barishal”, “Barishal”);
3.?>
e variable e store ,p e e u e p u e index
array’ 1 u e index/key c 0 e Dhaka[0],Chittagong[1]… e
e u e index number u l u
1.<?php
2.Print “$city[3]”;
3.?>
i a ei l ,=> ei a c ei u
a starting index 2 e ।
1.<?php
2.$city=array(2=>“Dhaka”, “Chittagong”, “Rajshahi”, “Sylet”, “Khulna”,
“Barishal”, “Barishal”);
3.?>
ei a u index я ।
a aa aa aa a ( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)
e k index/key i string o e i associative array :
1.<?php
2.$ages = array("adnan"=>32, "rezwan"=>30,"refat"=>34);
3.?>
l il il il i aaaa ( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL ARRAY)RAY)RAY)RAY)
e e a p u e a ei a p u o e a 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.?>
aaaa
FOREACH LOOPFOREACH LOOPFOREACH LOOPFOREACH LOOP
e associative array e t foreach statement e :
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 uei uei uei u ( PHP Funct i on)( PHP Funct i on)( PHP Funct i on)( PHP Funct i on)
: яoяoяoяo
e c e b e i b i c execution
e ei e k p 700 e o l i ei ।
e i e execute я я e ।
1.function functionName()
2.{
3.code to be executed;
4.}
: e i ।
ak _ , m ।
e simple
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
o ,e e PHP variable e i e
b
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 Rejoanul Alam.
My Father's name is Samad Alam.
My brother's name is Anjirul Alam.
u
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 Jack Black!
Hello there Ahmed Zewail!
Hello there Julie Roberts!
Hello there Charles Schwab!
e return return statement
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 uei uei uei u ( PHP For m)( PHP For m)( PHP For m)( PHP For m)
: яoяoяoяo
e k ei ’ e p e iuя ei ei я
e ei i e ei (iuя i ) -
$_GET e $_POST.e ei e e i l e ।
1.<form action="welcome.php" method="post">
2.Name: <input name="fname" />
3.Age: <input name="age" />
4.<input type="submit" />
5.</form>
iuя k ei i “welcome.php” e
я k method=POST ,Form e ei d
POST e GET.
welcome.php i e
1.Welcome <?php echo $_POST["fname"]; ?>!<br />
2.You are <?php echo $_POST["age"]; ?> years old.
e я rezwan e age 24,e k u e
Welcome rezwan!
You are 24 years old.
15.
eieieiei $_$_$_$_GETGETGETGET ( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod)
: яoяoяoяo
GET e b uя e p e i k
e c 250 character (e e b uя u URL e
)
1.<form action="welcome.php"method="get">
2.Name: <input name="fname" />
3.Age: <input name="age" />
4.<input />
5.</form>
iuя k b uя e
http://www.w3schools.com/welcome.php?fname=Peter&age=37
welcome.php i e $_GET Method g ।
1.Welcome <?php echo $_GET["fname"]; ?>.<br />
2.You are <?php echo $_GET["age"]; ?> years old!
16.
ei s uei s uei s uei s u ( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod)
: яoяoяoяo
ei d i u b uя e o p ।
e ic ( c 8Mb n )
<form action="welcome.php" method="post">
Name: <input name="fname" />
Age: <input name="age" />
<input />
</form>
e iuя k b uя e
http://www.w3schools.com/welcome.php
e $_POST Method d ।
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
al GET Method e iuя password i k t POST Method ।
BBBB....a n eia n eia n eia n ei
1.1.1.1.
a n ei ua n ei ua n ei ua n ei u |||| ( Advanced PHP( Advanced PHP( Advanced PHP( Advanced PHP Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)
: яoяoяoяo
webcoachbd.com e ei ei a n u - ei ,k , i , ,e
n i ।
2.
ei uei uei uei u ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)
: яoяoяoяo
eieieiei ( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)
o я / i ei e date() d e
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 n ।
3.
eieieiei i k ui k ui k ui k u ( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
i c i e k u i ei e e i a a ei i
include() ।
Require()- fatal error( ) e skp e k u n ।
Include()- e skp e k u
e a я e , , a o i
яi e e ei i ( , , i ) a я e
p я e ei include i
e я я i k я
u , “menu.php” e i aa
1.<a href="/default.php">Home</a>
2.<a href="/tutorials.php">Tutorials</a>
3.<a href="/references.php">References</a>
4.<a href="/examples.php">Examples</a>
5.<a href="/about.php">About Us</a>
6.<a href="/contact.php">Contact Us</a>
e 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.
eieieiei ( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)
: яoяoяoяo
require() include() e i t e u t e n ।
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) [function.include
failed to open stream
No such file or directory in C:homewebsitetest.php on line
Warning: include() [function.include
Failed opening 'wrongFile.php' for inclusio
(include_path='.;C:php5pear')
in C:homewebsitetest.php on line
Hello World!
Notice that the echo statement is executed! This is because a Warning does not stop the script
execution.
require() Function eeee eeee яяяя
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) [function.require
failed to open stream
No such file or directory in C:homewebsitetest.php on line
Fatal error: require() [function.require
Failed opening required 'wrongFile.php
(include_path='.;C:php5pear')
in C:homewebsitetest.php on line 5
echo statement e e k u i
5.
ei iei iei iei i uuuu ( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
fopen e ei i
1.<html>
2.<body>
3.<?php
4.$file=fopen("welcome.txt","r");
5.?>
6.</body>
7.</html>
fopen e b я e “welcome.txt”a ei i e d “r” e e
i a s ( ) e “r” i e read only ।
e
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
i fopen() function 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 i k яe i k яe i k яe i k я
fclose() function i n ।
1.<?php
2.$file = fopen("test.txt","r");
3.
4.//some code to be executed
5.
6.fclose($file);
7.?>
ENDENDENDEND---- OFOFOFOF---- FILEFILEFILEFILE
e i ।
if (feof($file)) echo "End of file";
e e я ।
e ie ie ie i LINE BY LINELINE BY LINELINE BY LINELINE BY LINE
fgets() function ei e e i ei i
i u e e e i n।
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 CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTERERERER e ie ie ie i
fgetc() function e i e e ak ।
u i e e ak ।
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 i uei i uei i uei i u ( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
ei iuя i
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" a k
s e upload_file.php i e upload_file.php e ।
Upload_file.php skp 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 ।
• $_FILES["file"]["name"] – i
• $_FILES["file"]["type"] - i type
• $_FILES["file"]["size"] - i size
• $_FILES["file"]["tmp_name"] i temporary copy k ।
i c i e t я u i
20 i a i .jpeg,.jpg,.gif
i i ।
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.?>
iiii
i u i as (temporary copy) ,s я e
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.?>
skp i ei i , move_uploaded_file
l i ।
u u “upload” e l i ।
7.
ei k uei k uei k uei k u ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)
: яoяoяoяo
e я iuя k e e c e i iuя (e /я
)।ধরুন i i e a k i я i i i
iuя i c ,i я i iuя e я c,e i i k
i ei (iuя o i ) k ।
kkkk
setcookie() function e k ।
setcookie() function a i <html> e ।
setcookie(name, value, expiration);
namename:e k , ei k ।
value:e k k , k c username(string)e last visit(date)
expiration:e oi k ei (k k )
b uя s i k ।
u e k iuя o i visit i k
e e я iuя i i k
e 30 a e oi s iuя ignore 30 e
i ।
1.<?php
2.$expire=time()+60*60*24*30;
3.setcookie("user", "rezwan",$expire);
4.?>
5.<html>
6......
k udk udk udk ud ((((RETRIEVERETRIEVERETRIEVERETRIEVE))))
k ei $_COOKIE variable k retrieve ।
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 e "lastVisit" k e o iuя ,
iuя visit ।
kkkk
k e k ।
view source
print?
1.<?php
2.// set the expiration date to one hour ago
3.setcookie("user", "", time()-3600);
4.?>
8.
ei uei uei uei u ( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)
: яoяoяoяo
e p я , , n n e e mu
я , e n in e -o
e k ei ei ei iuя
k я ei as e iuя i s
ei p iuя я a unique id (UID) ।
ei iuя k ei session_start()
e <html> tag e ।
1.<?php session_start(); ?>
2.
3.<html>
4.<body>
5.
6.</body>
7.</html>
ei iuя яs e ei e i ।
kkkk
k o ud 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 page view counter(page я ) я e я isset()
ei ‘views’ i ‘views’ variable
a counter ‘views’variable 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.?>
eeee ( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI ON)N)N)N)
unset() or the session_destroy() function ]
unset() function e ।
1.<?php
2.unset($_SESSION['views']);
3.?>
e m session_destroy() function ।
1.<?php
2.session_destroy();
3.?>
session_destroy() reset e e ।
9.
ei e h uei e h uei e h uei e h u ( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
ei skp o e p error handling e e t e
( ) p g e t я ।
ei u e e p d
"die()" statements
Custom errors and error triggers
Error reporting
""""DIEDIEDIEDIE()"()"()"()" ssss eeee hhhh
e e kk i ।
1.<?php
2.$file=fopen("welcome.txt","r");
3.?>
i a s i b uя p ।
Warning: fopen(welcome.txt) [function.fopen]: failed to open stream:
No such file or directory in C:webfoldertest.php on line 2
iuя u я k я я
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 i ei я ।
File not found
ei u e n e e d e error skp n e d
a ।
s e hs e hs e hs e h
e e ei e call ei k (error level and
error message) e c (optionally: file, line-number, and the error context) ।
error_function(error_level,error_message,error_file,error_line,error_context)
Parameter Description
error_level iuя error report level a i e
value number m error report level ।
error_message iuя я error message ।
error_file c i u l ।
error_line c i u l ।
error_context c e a u l (Specifies an array) e ।
e ee ee ee e ( VALUE)( VALUE)( VALUE)( VALUE)
Value Constant Description
2 E_WARNING run-time errors. sk p Execution n
8 E_NOTICE Run-time notices.
256 E_USER_ERROR iuя t e E_ERROR e 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 (E_STRICT
PHP 6.0
e E_ALL e a )
e ee ee ee e e h ee h ee h ee h e яnяnяnя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 e e e error level e я ei e я
u skp p ।
e he he he h
ei l e error handler li i c e я error handler
PHP u ei я error handler
set_error_handler("customError");
error handle я я i, i set_error_handler() e e
,2 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
TRIGGERTRIGGERTRIGGERTRIGGER
skp iuя i trigger u iuя /a i
trigger_error() function e ei u test 1 e 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:webfoldertest.php on line 6
e error sk p я trigger e error
level trigger ।
mmmm error eeee
• E_USER_ERROR
• E_USER_WARNING
• E_USER_NOTICE
u
test e 1 e e E_USER_WARNING error e e я
error handler ।
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] Value must be 1 or below
Ending Script
eeee
PHP error_log() e li e ic error log( )
e я i o।
i i ei i ei i ei i e яяяя
<?php
//error handler function
function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr<br />";
echo "Webmaster has been notified";
error_log("Error: [$errno] $errstr",1,
" someone@example.com","From: webmaster@example.com");
}
//set error handler
set_error_handler("customError",E_USER_WARNING);
//trigger error
$test=2;
if ($test>1)
{
trigger_error("Value must be 1 or below",E_USER_WARNING);
}
?>
u
Error: [512] Value must be 1 or below
Webmaster has been notified
ei e e i
Error: [512] Value must be 1 or below
10.
ei l uei l uei l uei l u ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)
: яoяoяoяo
a u iuя i ei l g (validate/acceptable) e
(filter) o e p e i t o e p i i u
o e p i i filter i
d я e t я n u -
• e i
• k
• o
•
•
e le le le l
filter -
• filter_var() – 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 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 "FILTER_VALIDATE_INT" d $int l ,e u "Integer is valid"
123 e integer.
VALIDATINGVALIDATINGVALIDATINGVALIDATING eeee SANI TI ZI NGSANI TI ZI NGSANI TI ZI NGSANI TI ZI NG
l 2
VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:
• user input validate
• ( URL E-Mail validating)
SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:
• e s e ak a я ।
• s return ।
OPTIONSOPTIONSOPTIONSOPTIONS eeee FLAGSFLAGSFLAGSFLAGS
Option e Flag l a k filtering option n l n option e
flag u e validate filter_var() l e "min_range" o "max_range"
option ।
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 options a i associative array e “options’’ flag
e a o я e 300 n i e u
"Integer is not valid".
VALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUT
p i я a st filter_input() function d
i l 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 ) "GET" method ।
1. i e "email" GET a st ।
2. i e a st e i i e ।
SANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUT
p i я a st filter_input() function d
i sanitize 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) "POST" method ।
1. i e "url" POST a st ।
2. i e a st sanitize(ap я ak ) e e $url variable e k
।
i e s "http://www.W3ååSchøøools.com/" $url variable sanitizing e
e ।
http://www.W3Schools.com/
e ie ie ie i llll
e e i l e e call e filter
filter_var_array the filter_input_array function
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.
eieieiei iiii ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)
: яo
PHP mail() d o я i i ।
1.mail(to,subject,message,headers,parameters)
to я ।e i i i i ।
subject я ।e u l ।
message я ।e я । я i (n) h d e i 70 ak
headers c ।e d a k । :From,Cc,Bcc.
parameters c ।a k ।
: i я s i i i s e php.ini i i a
>> c? b o i- i s p i
i s i e i e k k ।
e u i e p u n s c n
i u я a
e я ei i u e k я i
(a someone@example.com ei i )
PHP MAI L FORMPHP MAI L FORMPHP MAI L FORMPHP 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>
::::
p i i e
HTML i o
i o
ei 3 logic e ।
e k я reload e i i e i
।
::::e d e ei a iuя ie d e ei a iuя ie d e ei a iuя ie d e ei a iuя i
e i i i я ।i i i я ue i i i я ।i i i я ue i i i я ।i i i я ue i i i я ।i i i я u form validationform validationform validationform validation.... PHPPHPPHPPHP
llll ((((FilterFilterFilterFilter)))) a ua ua ua u
CCCC.... ei oei oei oei o
1.1.1.1.
ei o uei o uei o uei o u |||| ( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i al i nal i nal i nal i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
• ei o (PHP Framework) c e basic Platform/structure( ) o a p
।
• d , like k ei s я n (like) ,p я
j e i e e e e p e u ।
• PHP Framework e p -p ,
k,d a p ।
• e e o я ,e o o a , я i
।
я ei o (PHP Framework) e e o i s яi e o i
e i a ।
ei o (PHP Framework) я
1.PHP( PHP Function, Variable etc)
2.Object Oriented Programming
3.MVC(Model View Controller)Structure
a ei o яn o , , , i i i яn e i i
я p яn e я -яn en p iя ei e я i p i o
o я u i i , i e i i (CodeIgniter PHP
Framework) e u ।
2.
a яk a p g e eia яk a p g e eia яk a p g e eia яk a p g e ei ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)
: яoяoяoяo
p u ap u ap u ap u a p gp gp gp g ---- POP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENTED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG)
u language FORTRAN(Formula Translation-e Statistician
)COBOL,C i s i p g Procedure
Oriented Programming(POP).PHP o e p g POP
(instruction/actions) ,ei mu я ei g s
e p g e a ,p a i e p g e e + ।
e p g n я n e e p g i
i POP a global data k n
e o ।
a яk a pa яk a pa яk a pa яk a p gggg ---- OOP( OBJECTOOP( OBJECTOOP( OBJECTOOP( OBJECT ORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NG))))
OOP a яk a n p g (Object Oriented Programming) ei k
e OOP critical element e s k p (free flow) n OOP
e e Objects ,e я ei a яk e / sk
/ d k m /(interact)
OOPOOPOOPOOP
*e k ( ei operate )
* p g Object k a e p g a Object
*e Object e e ,ei (Operate )
* i ei e ।
* d e Object Object e ।
*e p g e ।
OOP
• Objects
• Class
• Encapsulation
• Inheritence
• Polymorphism
• Message passing
a яka яka яka яk ( OBJECTS)( OBJECTS)( OBJECTS)( OBJECTS)
a яk e ,ei ( ) a яk c e
(a bundle) e n e k k e a яk e k , k
я a я ko , k a яk c ei a яk
a ( )।কিন্তু e a o ।
a яk a n ei e a яk e / / (bunch).e g
я ei a яk e t я e u e s n ( ei skp ), e c
e (bunch) (a яk ), s n e я , p (a яk) я я я
m s nt ।
k ei ( d -Procrdure Oriented way) e
(bunch) sk pi ।
kkkk ( CLASS)( CLASS)( CLASS)( CLASS)
ei a яk ei a яk e я e /e l
(blueprint/template/outline) e p (e a яk e я ) k ।
k c a я k я (blueprint).e k c a я k я e e l e
e k я , a e k e a яk m e
a яk a n ei ei e living,breathing a яk k e u t
living,breathing a яk c ei a яk ।
e se se se s ( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON)
e k (class) e e i e e k e k e k
i e o a i ei p t ei k
i i i ei e i ei e n
o p k (data hiding/information hiding)
i ni ni ni n ( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE)
OOP i n : (reusability) p a e k a k
k i sk p e k e k ei k a
k k k (super class/base class) k e
k /p k (subclass/derived class).extends ei o k e k ।
яяяя ( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM)
e a яk e я e i n я ei p k я ।
я a kя a kя a kя a k ( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG)
e OO Program e e a яk e e e a a e a яk
a яk e я ei p k i я a k ।
3.
a яka яka яka яk aaaa eieieiei ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)
eeee u ।।।। e
ei 5 (PHP5) ei 5 m a яk a n e ei 4 m a яk
a n ei 5 a яk a n o e я , , o e p я
OOPHP ei , , n s n, i ।
u я e 23 a ( ) ।
---- ::::
pppp ei я rei я rei я rei я r
index.php
class_lib.php
a яk a n e i i i ei ‘includes’ ei
e я ei u я a яk a n class_lib.php i OOP
k я k c m p /k a яk e я a яk m ।
---- ::::
eeee ei kei kei kei k
ei sk p , , i a яk a n d
p i e k k я p i ‘class’ b e e k i c ।
1.<?php
2.class people{
3.
4.}
5.?>
---- ::::
kkkk
k c a я k я b pn/ k e ei
‘property’
1.<?php
2.class people{
3.var name;
4.}
5.?>
: e k / (ei u var name;) e ‘properties’
---- ::::
kkkk ////
e k e ‘properties’ e k e
‘methods’ ( k e ei )e
k /methods i k /properties ।
<?php
class people{
var $name;
function set_name($new_name){
$this->name=$new_name;
}
function get_name(){
return $this->name;
}
}
?>
k properties e ।
---- ::::
gettergettergettergetter eeee settersettersettersetter
/ get_name() e set_name() ei я e
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 e ei p g
a яk я i t set_name() / e
a i e property/variable ‘name’
---- ::::
‘$t hi s$t hi s$t hi s$t hi s’
m i
$this->name=$new_name
$this e li ( a я ki e l i ) a яk a e e self-
referencing e properties e e e e k
।
function get_name() {
return $this->name;
}
e e e ei o e ei ei
ei i я ।
---- ::::
ei я ei kei я ei kei я ei kei я ei k
ei я ei k a яk a n p g e u d i k
e ei я ei я e ‘include’ ‘require’ ।
<!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 ,e ।
---- ::::
a яka яka яka яk
e k a яk p k instantiation.
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
</body>
</html>
$rejoan people a яk e я n $rejoan ei people
a яk nt e я ।
---- ::::
newnewnewnew oooo
e k a яk ei new o p я ।
i c e k a a яk ei i я p a яk (s nt
st )
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
$riad = new people;
</body>
</html>
a яk k quote a e
$rejoan= new 'people';
---- ::::
a яka яka яka яk propertiespropertiespropertiesproperties ((((setsetsetset)))) ।।।।
a яk people ,e properties (set)
(the setters) ।
e o a яk e 2 ($rejoan e $riad) e i k people e u t
ei n m a ei e 2 a яk
m ।
<?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 ea я k ea я k ea я k e
e getter a я k e e i setter
a я k ।
k e properties e e i a (->) h ।
<?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 (=>) ei h n e ।
a n ei u a ।
:
e ei k я i
ei k u t e я a яk
a я k
a яk
-12:
a яka яka яka яk propertiespropertiespropertiesproperties e ee ee ee e ???? eeee
a я k properties e e , a (->) a
e u s :
$rejoan->name.
o e o e e e я d e
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 "Rejoan’s full name: " . $rejoan->name;
?>
</body>
</html>
---- ::::
sT ksT ksT ksT k
a я k e li s k e a я k properties e ।
:__construct() ei a __construct /
e k e a яk ।
‘construct’ n s (__) s k k e k
(e ) ei d ।
<?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 u k
functions=methods
variables=properties
-14:
constructconstructconstructconstruct e a яke a яke a яke a яk
e s k ,e people a яk $name property’
u :
$rejoan = new people("Rejoanul Alam");
e set_name() e sk p ।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoan’s full Name: " . $rejoan->get_name();
?>
</body>
</html>
e e u a яk a n ei e li (mechanism)
ei ।
---- ::::
propertiespropertiespropertiesproperties e e e d ।e e e d ।e e e d ।e e e d ।
a яk a n p g e e e (encapsulation).e a я k s
(properties) e e d ।
k properties e e d я ‘access modifier’ 3 e -
1. 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 (declare) e ‘public’ ।
-16:
propertiespropertiespropertiesproperties e e d ।ae e d ।ae e d ।ae e d ।a ----
e property private e i k e ।
property protected t e i k e p k (derived class/ei
k k p o k k properties e e ) ei k e
я e i k e p k k ।
public d i u sk p я e e ।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
/*
$pinn_number private i ei e ,p g i
*/
echo "Tell me private stuff: " . $rejoan->$pinn_number;
?>
</body>
</html>
---- ::::
e de de de d
properties e o ei 3 e e nt ।
1. public
2. private
3. protected
e ?
ut : e e , k a ei p g ei
e t e p я k e a ei p g я e
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;
}
}
?>
: get_pinn_number() e private i ei t k , k
sk p a o ei public ।
---- ::::
:::: ::::i ni ni ni n
a яk a n p g e i n (Inheritence) e d e k a
k /k k ।
e ?
ut :e d k : e k c
‘employee’ employee e people/person i e i e properties
।
e ?
ei a s i n e e i :
k n e d ei ।
1. sk p e i ।
2. : c i e a (a ) k n i e i
a ei ‘includes()’ e я ।
// 'extends' ei o i n
class employee extends people {
function __construct($employee_name) {
}
---- ::::
:::: ।a।a।a।a ----
employee k k people i employee k a people k
‘public’ properties, ei k (a ei k )।
// 'extends' ei o i n
class employee extends people {
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
k employee k set_name() o ei employee k
(declare) i ei i people k ।
-20:
:::: ।a।a।a।a ----
employee a я k get_name() people k я e
e d u (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 "Riad’s full name " . $riad->get_name();
?>
</body>
</html>
---- ::::
Over r i ddi ngOver r i ddi ngOver r i ddi ngOver r i ddi ng
( i n ) e k я e p я
।
u s set_name() people k n employee k ।
n people k set_name() Override employee k ei e i
।
<?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 i n
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() people k ( k ) n employee k
।
-22:
OverridingOverridingOverridingOverriding....aaaa ----
o k e , i k p k (e child k o
) override ।
u employee k set_name() override e e
people::set_name($new_name);
e parent k (People) set_name() e ।
<?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);
}
}
?>
---- ::::
overridingoverridingoverridingoverriding aaaa ----
'people::set_name()' e ei i я people k set_name() я
।
d parent o k parent k ( k
parent k ) ।
<?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);
}
}
?>
::::
a яk a n p g e e e OOPHP e я
я a я e OOP k d я e e
, я a яk e n я
e 8/10 e a яk k я ।
OOPOOPOOPOOP e p ge p ge p ge p g
a яk a n p g o e d a я e ei
я , ei , , ++ i ।
o я a яk a n i e я e i
o s e p ( o ) o e p
(o ) i OOP e u a яk
a n ei i i e я ।
e e e i , ei p я k я p a s e я e я
n e s n p яk a яk nd
eя a яk p яk g k g -
Ø o я ।
Ø p a яk p яn я k k
Ø ei k e properties e
Ø a e a яk m (parent-child/base-derived)
4.
u T sT uu T sT uu T sT uu T sT u ( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
u n s MVC Structure (e я i d ) ei e p
я
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 ei m i a a m u n
я i ei e ei MVC Structure 3 n я
e i e я ei 3
(Model)
u (View)
n (Controller)
( MODEL) :( MODEL) :( MODEL) :( MODEL) :
i i e e p ,ei e p a t
(a я ) d i , , i
a a s p яn ei я я я (business logic)
uuuu ( VI EW) :( VI EW) :( VI EW) :( VI EW) :
e s d iuя e я a e e o я ei e e
я i i e e я e a o я , , e e я i ।
TTTT ( CONTROLLER) :( CONTROLLER) :( CONTROLLER) :( CONTROLLER) :
n s d e u e я e a a e u
я ei я e ।
i i o MVC a u n s e t я a e e
।
5.
i i ui i ui i ui i u e i se i se i se i s ( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l
Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)
: яoяoяoяo
p http://codeigniter.com/downloads/e i i o u , e .zip format e
e я e o , я c i e c
htdocs folder,e ei F:Program Filesxampphtdocs. e C Drive e C
drive e F i F c ei C:Program Filesxampphtdocs. e e
u (e я ) l a s l CodeIgniter.
e i i l e system>>application>> config>>config.php i 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.
i ii ii ii i ( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n
Bangl a)Bangl a)Bangl a)Bangl a)
: яoяoяoяo
e “config.php” i o database.php e i e e
।
01.$active_group = "default";
02.$active_record = TRUE;
03.
04.
05.$db['default']['hostname'] = "localhost";
06.$db['default']['username'] = "root";
07.$db['default']['password'] = "mypassword";
08.$db['default']['database'] = "mydatabase";
09.$db['default']['dbdriver'] = "mysql";
10.$db['default']['dbprefix'] = "";
11.$db['default']['pconnect'] = TRUE;
12.$db['default']['db_debug'] = TRUE;
13.$db['default']['cache_on'] = FALSE;
14.$db['default']['cachedir'] = "";
15.$db['default']['char_set'] = "utf8";
16.$db['default']['dbcollat'] = "utf8_general_ci";
e address bar e http://localhost/CodeIgniter/ en a i s ।
7.
i i e p e pi i e p e pi i e p e pi i e p e p ( Cr eat i ng Fi r st( Cr eat i ng Fi r st( Cr eat i ng Fi r st( Cr eat i ng Fi r st Appl i cat i on wi t hAppl i cat i on wi t hAppl i cat i on wi t hAppl i cat i on wi t h
CodeI gni t er )CodeI gni t er )CodeI gni t er )CodeI gni t er )
: яoяoяoяo
c ei u OOP e OOPHP e u e e
a яk a n p g e i i e a u o
, p ।
i i MVC Structure e t ,e o e p я
ei d я я ( a ),e p я ( n a )e я я ( u a
) i e e p e e p c ei e p
n e u e e я i i e o я i।
F:Program FilesxampphtdocsCodeIgnitersystemapplicationcontrollers ei e
helloworld.php i (F e я C ) ei i e ++ e
e class e
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 k e c k /p k / k k 'Controller'
ei 'Controller' k i i i e c k / n k ei n
k 'Controller' extends o k 'HellowWorld' p
(derived).
e parent::Controller() e function index() d ei c n k (Controller e) o
e index() ( ) p $data (a ) e d u
p ei n i m p 'helloworld.php'।কোডইগনাইটারে loader e k
, n e k i ei loader k a i l e i i ei
loader k u i я e
$this->load->view('helloworld',$data);
e u i e e pass b uя u i e
F:Program FilesxampphtdocsCodeIgnitersystemapplicationviews ei helloworld.php
e i i
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
: Controller e Views folder e k welcome.php e welcome_message.php i
++ e a ।
5. php bangla tutorial php basic

More Related Content

What's hot

PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacy
Damien Seguy
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?
Francois Zaninotto
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
Wim Godden
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
julien pauli
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
Wim Godden
 
Elegant concurrency
Elegant concurrencyElegant concurrency
Elegant concurrency
Mosky Liu
 
The WordPress Loop
The  WordPress LoopThe  WordPress Loop
The WordPress Loop
Giustino Borzacchiello
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
Wim Godden
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
weltling
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
Wim Godden
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
Mosky Liu
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
Damien Seguy
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
Krasimir Berov (Красимир Беров)
 

What's hot (15)

PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacy
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Elegant concurrency
Elegant concurrencyElegant concurrency
Elegant concurrency
 
The WordPress Loop
The  WordPress LoopThe  WordPress Loop
The WordPress Loop
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 

Similar to 5. php bangla tutorial php basic

Synapseindia reviews on array php
Synapseindia reviews on array phpSynapseindia reviews on array php
Synapseindia reviews on array php
saritasingh19866
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
SynapseindiaComplaints
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
SynapseindiaComplaints
 
Orange@php conf
Orange@php confOrange@php conf
Orange@php conf
Hash Lin
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧
Orange Tsai
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
 
Synapseindia php development tutorial
Synapseindia php development tutorialSynapseindia php development tutorial
Synapseindia php development tutorial
Synapseindiappsdevelopment
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
Anshu Prateek
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
Quinn Wilton
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
Unmesh Baile
 
Brian hogg word camp preparing a plugin for translation
Brian hogg   word camp preparing a plugin for translationBrian hogg   word camp preparing a plugin for translation
Brian hogg word camp preparing a plugin for translation
wcto2017
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
rICh morrow
 
Preparing a WordPress Plugin for Translation
Preparing a WordPress Plugin for TranslationPreparing a WordPress Plugin for Translation
Preparing a WordPress Plugin for Translation
Brian Hogg
 
php fundamental
php fundamentalphp fundamental
php fundamental
zalatarunk
 
php
phpphp
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
pooja bhandari
 
Php
PhpPhp
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
Chris Ramakers
 

Similar to 5. php bangla tutorial php basic (20)

Synapseindia reviews on array php
Synapseindia reviews on array phpSynapseindia reviews on array php
Synapseindia reviews on array php
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
 
Orange@php conf
Orange@php confOrange@php conf
Orange@php conf
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
Synapseindia php development tutorial
Synapseindia php development tutorialSynapseindia php development tutorial
Synapseindia php development tutorial
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 
Brian hogg word camp preparing a plugin for translation
Brian hogg   word camp preparing a plugin for translationBrian hogg   word camp preparing a plugin for translation
Brian hogg word camp preparing a plugin for translation
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Preparing a WordPress Plugin for Translation
Preparing a WordPress Plugin for TranslationPreparing a WordPress Plugin for Translation
Preparing a WordPress Plugin for Translation
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
php
phpphp
php
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
Php
PhpPhp
Php
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 

Recently uploaded

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

5. php bangla tutorial php basic

  • 1. eieieiei AAAA.... eieieiei 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 BBBB....a n eia n eia n eia n ei • 1111....a n ei ua n ei ua n ei ua n ei u |||| ( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a) • 2222.... ei uei uei uei u ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a) • 3333.... ei i k uei i k uei i k uei i k u ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a) • 4444.... eieieiei ( PHP r eq( PHP r eq( PHP r eq( PHP r equi r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a) • 5555.... ei i uei i uei i uei i u ( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a) • 6666.... ei i uei i uei i uei i u ( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a) 7777.... ei kei kei kei k uuuu ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a) • 8888.... ei uei uei uei u ( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a) • 9999.... ei e h uei e h uei e h uei e h u ( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a) • 10.10.10.10. eieieiei iiii ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a) • 11111111.... ei l uei l uei l uei l u ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a) CCCC.... ei oei oei oei o • 1111.... ei o uei o uei o uei o u |||| ( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a) • 2222....a яk a p g e eia яk a p g e eia яk a p g e eia яk a p g e ei ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a) • a яka яka яka яk aaaa eieieiei ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a) • :::: ---- |||||||| ::::6666---- 10101010 |||||||| : 11: 11: 11: 11---- 15 | |15 | |15 | |15 | | : 16: 16: 16: 16---- 23232323
  • 2. • 4444.... i i u e i si i u e i si i u e i si i u e i s ( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n( CodeI gni t er Downl oad & I nst al l Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) • 5. u T sT uu T sT uu T sT uu T sT u ( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a) • 6666.... i ii ii ii i ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a) • 7777.... i ii ii ii i e p e pe p e pe p e pe p e p ( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er ) AAAA.... eieieiei 1.1.1.1. ei uei uei uei u |||| ( PHP Basi c)( PHP Basi c)( PHP Basi c)( PHP Basi c) : яoяoяoяo ei e i sk p m e я : sk p c p g b e c instruction e run s k я ।“ iiii ” c ei skp iuя mu nt handle u ei o я я o ei Process : (Picture,Content etc) (math calculation,file operation etc) e HTML e n iuя o b uя । eieieiei (PHP) ?: PHP Hypertext Preprocessor e i ,k p ,HTML-embedded sk p я ei e syntax C,Perl,Java ei я u d o я d i । eieieiei (PHP) яяяя : 1.HTML . HTML Form. 2. C я । 3.я skp o p яo p яo p яo p я ?:?:?:?: o ei hosting(я ) e я e s
  • 3. । я я mu i o i s e я m k o i s mu - * oooo 1.e PHP -compitable o : apache 2.PHP *k ink ink ink in oooo 1.o b uя я k(e i s i ) 2.e k e : ei e я Specialized e o s । webcoachbd.com eeee uuuu eieieiei ।।।। 2. ei i sei i sei i sei i s ( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a) : яoяoяoяo p u e k in o i e i s o apache e a i ei e o o i s :MySQL, я e o o e k o я e я c e e e o i s e i i s i s o c XAMPP.XAMPP e u i s http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe a o e i s । in s XAMPP e e i k o a a - i i s i e XAMPP Control Panel i a C i i s C:Program Filesxampp C:xampp ei e start click (Apache e MySql)।
  • 4. Apache o MySql b uя e http://localhost e я English k । ei я i s mn a mu e я ( ) 3.
  • 5. eieieiei ( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng) : яoяoяoяo C driveC driveC driveC drive eeee XAMPPXAMPPXAMPPXAMPP i s ei li s ei li s ei li s ei l htdocshtdocshtdocshtdocs llll web contentweb contentweb contentweb content g ।g ।g ।g । www k n i k c “C:xampphtdocs”( a i i s :D drive e “D:xampphtdocs”). e ei i k “mytest.php” i e a e -b uя e http://localhost/mytest.php c e , e ? ? ei я s iя o : Net Beans, Dreamweaver i e a e i , e IDE (Integrated Development Environment). c n । 4. eieieiei uuuu ( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a) : яoяoяoяo ei я a i i extension .php .html ei execute । * ei e p a <?php h e ?> h । * e ei Scripting Block(<?php e ?> e e b ) k n । *p instruction(code line) k d । o e e ( / ) e <?php echo"This is my first php page"; ?> e я mypage.php , htdocs browse save in e я e b uя e http://localhost/mypage.php e en u ।
  • 6. ei e u я s n echo o print. ei nnnn: h ei e e execute e , a m e n e i n i // # i n i /* e */ h । : a p , k ki <?php e ?> echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; e k । <?php echo "Hello World!"; echo "Hello World!"; ?> ei s я ,e p я । 5. ei uei uei uei u ( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a) : яoяoяoяo c e t (Container) a e kk String “Hello Bangladesh” a e integer value 100. e e e ( e e declare ) я , (value)
  • 7. ei “$” ei h a i я । * case sensitive. $a_number and $A_number , ei e । * m k ei $variable_name = Value; u i - 1.<?php 2.$hello = "Hello World!"; 3.$a_number = 4; 4.$anotherNumber = 8; 5.?> * ei e “Loosely Typed” я i declare e i ( ) u l o ei я i n । d : 1.a i letter or “_”(under score) । 2. alpha-numeric characters o underscores. a-z, A-Z, 0-9, or _ . । 3. s e a “___”underscore ($my_string) a ak ($myString) । 6. ei sT uei sT uei sT uei sT u ( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a) : яoяoяoяo ei s e k o । ei Career e ei s e t i e । s e e s e a e store e i s ,e store echo । 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 d s echo , store i e я i s e p i e store । c e u k b uя u ।
  • 8. e k Double quotes d s e Single quotes d s e i , o apostrophes । 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.?> s e single quotes e - echo ‘PHP it’s neat’ e double quotes e single quotes e i। ei d e p g я e k t , n ei e o i s quotation i heredoc,e s e - 1.<?php 2.$my_string = <<<TEST 3.He will be succeeded here 4.and here after! 5.TEST; 6.echo $my_string; 7.?> e s я a i - *<<< identifier heredoc TEST । * o e e k । *e яi e i ,(indent) i । u <br>( i b я ) s e ।
  • 9. 7. ei a uei a uei a uei a u ( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s) : яoяoяoяo a - manipulate 3 a 1.Unary – e (operand) я । 2.Binary- । 3.Ternary- 3 । e Operator a d -Arithmetic, Assignment, Comparison Operator etc. a i aa i aa i aa i a ( ASSI GNMENT OPERAT( ASSI GNMENT OPERAT( ASSI GNMENT OPERAT( ASSI GNMENT OPERATOR)OR)OR)OR) e aaaa e a e । $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
  • 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 - aaaa ( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR)))) ei Operator e relationship ei Operator n statement e statement true false. e 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
  • 11. > Greater than $x>$y False <= Less than equal to $x<=$y True >= Greater than equal to $x>=$y False sT asT asT asT a ( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR) e i o -“”, ‘’ ARI THMETI CARI THMETI CARI THMETI CARI THMETI C eeee ASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATOR e COMBI NATI ONe COMBI NATI ONe COMBI NATI ONe COMBI NATI ON Programming e e я c e , k t 1 i $counter=$counter+1; k e $counter+=1; Pre/Post-Increment eeee Pre/Post-Decrement: u e ad ,e 1 $x++ $x += 1; a $x = $x + 1 e । k t “-” a । 8. ei sei sei sei s ( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement ) : яoяoяoяo u action я n s n o i e e feature i u i 12 “Good Morning” u 5 “Good evening” ei e o я o a n я Conditional statement e ,condition e u t ei s k я i । ei Conditional statement - *if statement *if…else statement *if…elseif…else statement *Switch statement * I F STATEMENT* I F STATEMENT* I F STATEMENT* I F STATEMENT
  • 12. if statement execute condition true u u Have a nice day Saturday । 1.<?php 2.$d=date("D"); 3.if ($d=="Sat") 4.echo "Have a nice Day"; 5.?> * I F* I F* I F* I F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT c o e , , i e i if…else statement e u e 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 true a Saturday u Have a nice day Today is not Saturday. * I F* I F* I F* I F…ELSEI FELSEI FELSEI FELSEI F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT ei statement d e e b execute । 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.
  • 13. ei uei uei uei u ( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a) : яoяoяoяo e я i e i 50 i e e i 100 я i p g e я c e n i ei t я i i e । c e e statement e b execute k я । 4 - While Loop Do…while Loop For Loop Foreach Loop 10. eieieiei WhileWhileWhileWhile : яoяoяoяo e condition true while e b execute । 1.while (condition) 2.{ 3.code to be executed; 4.} condition false b e b condition ,true execute condition e e i : 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 k k I e 5 p 1
  • 14. 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 ? i e while loop e i execute । DODODODO…WHI LE LOOPWHI LE LOOPWHI LE LOOPWHI LE LOOP e while loop e i e k condition test , , while e a k e execute i। 1.Do 2.{ 3.Code to be executed 4.} 5.While(condition); u o u 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 i=6 i ? This is line 6 This line is outside while loop.so it will not repeat. p i e execute p execution e repeat ? n while loop e p i ei । 11. ei uei uei uei u ( PHP For Loop)( PHP For Loop)( PHP For Loop)( PHP For Loop) : яoяoяoяo
  • 15. ei e я e я while o , e । 1.for (init; condition; increment) 2.{ 3.code to be executed; 4.} for loop statement b 3 expression k d k 1 assignment statement(loop control variable),p t i e e execution 2 Boolean expression p t i e e (evaluate) ,ei true t false return t n 3 loop control variable e u i=1 e e k I e 5 e I e 1 । 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 expression e e expression , d k Boolean expression e default true ei u u 1-10 । foreach loop e array e i 12. ei a uei a uei a uei a u ( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a) : яoяoяoяo e e single value e t(container). n a e value’ container t e a u p u value -key index u । s e e single variable e store e - $city1= “Dhaka” $city2= “Chittagong”
  • 16. $city3= “Rajshahi” $city4= “Sylet” $city5= “Khulna” $city6= “Barishal” n e a e e e a d c u k (series of element) u index 0 k a я c- 1.<?php 2.$city=array(“Dhaka”, “Chittagong”, “Rajshahi”, Sylet”, “Khulna”, “Barishal”, “Barishal”); 3.?> e variable e store ,p e e u e p u e index array’ 1 u e index/key c 0 e Dhaka[0],Chittagong[1]… e e u e index number u l u 1.<?php 2.Print “$city[3]”; 3.?> i a ei l ,=> ei a c ei u a starting index 2 e । 1.<?php 2.$city=array(2=>“Dhaka”, “Chittagong”, “Rajshahi”, “Sylet”, “Khulna”, “Barishal”, “Barishal”); 3.?> ei a u index я । a aa aa aa a ( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY) e k index/key i string o e i associative array : 1.<?php 2.$ages = array("adnan"=>32, "rezwan"=>30,"refat"=>34); 3.?> l il il il i aaaa ( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL ARRAY)RAY)RAY)RAY) e e a p u e a ei a p u o e a 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.?> aaaa
  • 17. FOREACH LOOPFOREACH LOOPFOREACH LOOPFOREACH LOOP e associative array e t foreach statement e : 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 uei uei uei u ( PHP Funct i on)( PHP Funct i on)( PHP Funct i on)( PHP Funct i on) : яoяoяoяo e c e b e i b i c execution e ei e k p 700 e o l i ei । e i e execute я я e । 1.function functionName() 2.{ 3.code to be executed; 4.} : e i । ak _ , m । e simple 01.<?php
  • 18. 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 o ,e e PHP variable e i e b 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 Rejoanul Alam. My Father's name is Samad Alam. My brother's name is Anjirul Alam. u 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 Jack Black! Hello there Ahmed Zewail! Hello there Julie Roberts! Hello there Charles Schwab!
  • 19. e return return statement 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 uei uei uei u ( PHP For m)( PHP For m)( PHP For m)( PHP For m) : яoяoяoяo e k ei ’ e p e iuя ei ei я e ei i e ei (iuя i ) - $_GET e $_POST.e ei e e i l e । 1.<form action="welcome.php" method="post"> 2.Name: <input name="fname" /> 3.Age: <input name="age" /> 4.<input type="submit" /> 5.</form> iuя k ei i “welcome.php” e я k method=POST ,Form e ei d
  • 20. POST e GET. welcome.php i e 1.Welcome <?php echo $_POST["fname"]; ?>!<br /> 2.You are <?php echo $_POST["age"]; ?> years old. e я rezwan e age 24,e k u e Welcome rezwan! You are 24 years old. 15. eieieiei $_$_$_$_GETGETGETGET ( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod) : яoяoяoяo GET e b uя e p e i k e c 250 character (e e b uя u URL e ) 1.<form action="welcome.php"method="get"> 2.Name: <input name="fname" /> 3.Age: <input name="age" /> 4.<input /> 5.</form> iuя k b uя e http://www.w3schools.com/welcome.php?fname=Peter&age=37 welcome.php i e $_GET Method g । 1.Welcome <?php echo $_GET["fname"]; ?>.<br /> 2.You are <?php echo $_GET["age"]; ?> years old! 16. ei s uei s uei s uei s u ( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod) : яoяoяoяo ei d i u b uя e o p । e ic ( c 8Mb n ) <form action="welcome.php" method="post"> Name: <input name="fname" /> Age: <input name="age" /> <input />
  • 21. </form> e iuя k b uя e http://www.w3schools.com/welcome.php e $_POST Method d । Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. al GET Method e iuя password i k t POST Method । BBBB....a n eia n eia n eia n ei 1.1.1.1. a n ei ua n ei ua n ei ua n ei u |||| ( Advanced PHP( Advanced PHP( Advanced PHP( Advanced PHP Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a) : яoяoяoяo webcoachbd.com e ei ei a n u - ei ,k , i , ,e n i । 2. ei uei uei uei u ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a) : яoяoяoяo eieieiei ( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON) o я / i ei e date() d e 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
  • 22. e n । 3. eieieiei i k ui k ui k ui k u ( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n( PHP I ncl ude Funct i on Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo i c i e k u i ei e e i a a ei i include() । Require()- fatal error( ) e skp e k u n । Include()- e skp e k u e a я e , , a o i яi e e ei i ( , , i ) a я e p я e ei include i e я я i k я u , “menu.php” e i aa 1.<a href="/default.php">Home</a> 2.<a href="/tutorials.php">Tutorials</a> 3.<a href="/references.php">References</a> 4.<a href="/examples.php">Examples</a> 5.<a href="/about.php">About Us</a> 6.<a href="/contact.php">Contact Us</a> e 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. eieieiei ( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a) : яoяoяoяo require() include() e i t e u t e n ।
  • 23. 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) [function.include failed to open stream No such file or directory in C:homewebsitetest.php on line Warning: include() [function.include Failed opening 'wrongFile.php' for inclusio (include_path='.;C:php5pear') in C:homewebsitetest.php on line Hello World! Notice that the echo statement is executed! This is because a Warning does not stop the script execution. require() Function eeee eeee яяяя 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) [function.require failed to open stream No such file or directory in C:homewebsitetest.php on line Fatal error: require() [function.require Failed opening required 'wrongFile.php (include_path='.;C:php5pear') in C:homewebsitetest.php on line 5 echo statement e e k u i
  • 24. 5. ei iei iei iei i uuuu ( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n( PHP Fi l e Funct i on Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo fopen e ei i 1.<html> 2.<body> 3.<?php 4.$file=fopen("welcome.txt","r"); 5.?> 6.</body> 7.</html> fopen e b я e “welcome.txt”a ei i e d “r” e e i a s ( ) e “r” i e read only । e 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 i fopen() function 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 i k яe i k яe i k яe i k я
  • 25. fclose() function i n । 1.<?php 2.$file = fopen("test.txt","r"); 3. 4.//some code to be executed 5. 6.fclose($file); 7.?> ENDENDENDEND---- OFOFOFOF---- FILEFILEFILEFILE e i । if (feof($file)) echo "End of file"; e e я । e ie ie ie i LINE BY LINELINE BY LINELINE BY LINELINE BY LINE fgets() function ei e e i ei i i u e e e i n। 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 CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTERERERER e ie ie ie i fgetc() function e i e e ak । u i e e ak । 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.?>
  • 26. 6. ei i uei i uei i uei i u ( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n( PHP Fi l e Upl oad Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo ei iuя i 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" a k s e upload_file.php i e upload_file.php e । Upload_file.php skp 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 । • $_FILES["file"]["name"] – i • $_FILES["file"]["type"] - i type • $_FILES["file"]["size"] - i size • $_FILES["file"]["tmp_name"] i temporary copy k । i c i e t я u i 20 i a i .jpeg,.jpg,.gif i i ।
  • 27. 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.?> iiii i u i as (temporary copy) ,s я e 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.{
  • 28. 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.?> skp i ei i , move_uploaded_file l i । u u “upload” e l i । 7. ei k uei k uei k uei k u ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a) : яoяoяoяo e я iuя k e e c e i iuя (e /я )।ধরুন i i e a k i я i i i iuя i c ,i я i iuя e я c,e i i k i ei (iuя o i ) k । kkkk setcookie() function e k । setcookie() function a i <html> e । setcookie(name, value, expiration); namename:e k , ei k । value:e k k , k c username(string)e last visit(date) expiration:e oi k ei (k k ) b uя s i k । u e k iuя o i visit i k e e я iuя i i k e 30 a e oi s iuя ignore 30 e i । 1.<?php 2.$expire=time()+60*60*24*30;
  • 29. 3.setcookie("user", "rezwan",$expire); 4.?> 5.<html> 6...... k udk udk udk ud ((((RETRIEVERETRIEVERETRIEVERETRIEVE)))) k ei $_COOKIE variable k retrieve । 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 e "lastVisit" k e o iuя , iuя visit । kkkk k e k । view source print? 1.<?php 2.// set the expiration date to one hour ago 3.setcookie("user", "", time()-3600); 4.?> 8. ei uei uei uei u ( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a) : яoяoяoяo e p я , , n n e e mu я , e n in e -o e k ei ei ei iuя k я ei as e iuя i s ei p iuя я a unique id (UID) । ei iuя k ei session_start() e <html> tag e । 1.<?php session_start(); ?> 2. 3.<html> 4.<body>
  • 30. 5. 6.</body> 7.</html> ei iuя яs e ei e i । kkkk k o ud 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 page view counter(page я ) я e я isset() ei ‘views’ i ‘views’ variable a counter ‘views’variable 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.?> eeee ( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI ON)N)N)N) unset() or the session_destroy() function ] unset() function e । 1.<?php 2.unset($_SESSION['views']); 3.?>
  • 31. e m session_destroy() function । 1.<?php 2.session_destroy(); 3.?> session_destroy() reset e e । 9. ei e h uei e h uei e h uei e h u ( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n( PHP Er r or Handl er Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo ei skp o e p error handling e e t e ( ) p g e t я । ei u e e p d "die()" statements Custom errors and error triggers Error reporting """"DIEDIEDIEDIE()"()"()"()" ssss eeee hhhh e e kk i । 1.<?php 2.$file=fopen("welcome.txt","r"); 3.?> i a s i b uя p । Warning: fopen(welcome.txt) [function.fopen]: failed to open stream: No such file or directory in C:webfoldertest.php on line 2 iuя u я k я я 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 i ei я । File not found
  • 32. ei u e n e e d e error skp n e d a । s e hs e hs e hs e h e e ei e call ei k (error level and error message) e c (optionally: file, line-number, and the error context) । error_function(error_level,error_message,error_file,error_line,error_context) Parameter Description error_level iuя error report level a i e value number m error report level । error_message iuя я error message । error_file c i u l । error_line c i u l । error_context c e a u l (Specifies an array) e । e ee ee ee e ( VALUE)( VALUE)( VALUE)( VALUE) Value Constant Description 2 E_WARNING run-time errors. sk p Execution n 8 E_NOTICE Run-time notices. 256 E_USER_ERROR iuя t e E_ERROR e 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 (E_STRICT PHP 6.0 e E_ALL e a ) e ee ee ee e e h ee h ee h ee h e яnяnяnяn 1.function customError($errno, $errstr) 2.{ 3.echo "<b>Error:</b> [$errno] $errstr<br />";
  • 33. 4.echo "Ending Script"; 5.die(); 6.} e e error handling e e e error level e я ei e я u skp p । e he he he h ei l e error handler li i c e я error handler PHP u ei я error handler set_error_handler("customError"); error handle я я i, i set_error_handler() e e ,2 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 TRIGGERTRIGGERTRIGGERTRIGGER skp iuя i trigger u iuя /a i trigger_error() function e ei u test 1 e 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:webfoldertest.php on line 6 e error sk p я trigger e error
  • 34. level trigger । mmmm error eeee • E_USER_ERROR • E_USER_WARNING • E_USER_NOTICE u test e 1 e e E_USER_WARNING error e e я error handler । 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] Value must be 1 or below Ending Script eeee PHP error_log() e li e ic error log( ) e я i o। i i ei i ei i ei i e яяяя <?php //error handler function function customError($errno, $errstr) { echo "<b>Error:</b> [$errno] $errstr<br />"; echo "Webmaster has been notified";
  • 35. error_log("Error: [$errno] $errstr",1, " someone@example.com","From: webmaster@example.com"); } //set error handler set_error_handler("customError",E_USER_WARNING); //trigger error $test=2; if ($test>1) { trigger_error("Value must be 1 or below",E_USER_WARNING); } ?> u Error: [512] Value must be 1 or below Webmaster has been notified ei e e i Error: [512] Value must be 1 or below 10. ei l uei l uei l uei l u ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a) : яoяoяoяo a u iuя i ei l g (validate/acceptable) e (filter) o e p e i t o e p i i u o e p i i filter i d я e t я n u - • e i • k • o • • e le le le l filter - • filter_var() – e l e filter । • filter_var_array() – e i n l e l ।
  • 36. • filter_input – e i e l • filter_input_array – e i e e i n l l । • u filter_var() function e 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 "FILTER_VALIDATE_INT" d $int l ,e u "Integer is valid" 123 e integer. VALIDATINGVALIDATINGVALIDATINGVALIDATING eeee SANI TI ZI NGSANI TI ZI NGSANI TI ZI NGSANI TI ZI NG l 2 VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS: • user input validate • ( URL E-Mail validating) SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS: • e s e ak a я । • s return । OPTIONSOPTIONSOPTIONSOPTIONS eeee FLAGSFLAGSFLAGSFLAGS Option e Flag l a k filtering option n l n option e flag u e validate filter_var() l e "min_range" o "max_range" option । 01.<?php 02.$var=300; 03. 04.$int_options = array( 05."options"=>array 06.( 07."min_range"=>0,
  • 37. 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 options a i associative array e “options’’ flag e a o я e 300 n i e u "Integer is not valid". VALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUT p i я a st filter_input() function d i l 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 ) "GET" method । 1. i e "email" GET a st । 2. i e a st e i i e । SANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUT p i я a st filter_input() function d i sanitize u 01.<?php 02.if(!filter_has_var(INPUT_POST, "url"))
  • 38. 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) "POST" method । 1. i e "url" POST a st । 2. i e a st sanitize(ap я ak ) e e $url variable e k । i e s "http://www.W3ååSchøøools.com/" $url variable sanitizing e e । http://www.W3Schools.com/ e ie ie ie i llll e e i l e e call e filter filter_var_array the filter_input_array function 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 />");
  • 39. 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. eieieiei iiii ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a) : яo PHP mail() d o я i i । 1.mail(to,subject,message,headers,parameters) to я ।e i i i i । subject я ।e u l । message я ।e я । я i (n) h d e i 70 ak headers c ।e d a k । :From,Cc,Bcc. parameters c ।a k । : i я s i i i s e php.ini i i a >> c? b o i- i s p i i s i e i e k k । e u i e p u n s c n i u я a e я ei i u e k я i (a someone@example.com ei i ) PHP MAI L FORMPHP MAI L FORMPHP MAI L FORMPHP MAI L FORM <html>
  • 40. <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> :::: p i i e HTML i o i o ei 3 logic e । e k я reload e i i e i । ::::e d e ei a iuя ie d e ei a iuя ie d e ei a iuя ie d e ei a iuя i e i i i я ।i i i я ue i i i я ।i i i я ue i i i я ।i i i я ue i i i я ।i i i я u form validationform validationform validationform validation.... PHPPHPPHPPHP llll ((((FilterFilterFilterFilter)))) a ua ua ua u
  • 41. CCCC.... ei oei oei oei o 1.1.1.1. ei o uei o uei o uei o u |||| ( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i al i nal i nal i nal i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo • ei o (PHP Framework) c e basic Platform/structure( ) o a p । • d , like k ei s я n (like) ,p я j e i e e e e p e u । • PHP Framework e p -p , k,d a p । • e e o я ,e o o a , я i । я ei o (PHP Framework) e e o i s яi e o i e i a । ei o (PHP Framework) я 1.PHP( PHP Function, Variable etc) 2.Object Oriented Programming 3.MVC(Model View Controller)Structure a ei o яn o , , , i i i яn e i i я p яn e я -яn en p iя ei e я i p i o o я u i i , i e i i (CodeIgniter PHP Framework) e u । 2. a яk a p g e eia яk a p g e eia яk a p g e eia яk a p g e ei ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a) : яoяoяoяo
  • 42. p u ap u ap u ap u a p gp gp gp g ---- POP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENTED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG) u language FORTRAN(Formula Translation-e Statistician )COBOL,C i s i p g Procedure Oriented Programming(POP).PHP o e p g POP (instruction/actions) ,ei mu я ei g s e p g e a ,p a i e p g e e + । e p g n я n e e p g i i POP a global data k n e o । a яk a pa яk a pa яk a pa яk a p gggg ---- OOP( OBJECTOOP( OBJECTOOP( OBJECTOOP( OBJECT ORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NG)))) OOP a яk a n p g (Object Oriented Programming) ei k e OOP critical element e s k p (free flow) n OOP e e Objects ,e я ei a яk e / sk / d k m /(interact) OOPOOPOOPOOP *e k ( ei operate ) * p g Object k a e p g a Object *e Object e e ,ei (Operate ) * i ei e । * d e Object Object e । *e p g e । OOP • Objects • Class • Encapsulation • Inheritence • Polymorphism • Message passing a яka яka яka яk ( OBJECTS)( OBJECTS)( OBJECTS)( OBJECTS) a яk e ,ei ( ) a яk c e (a bundle) e n e k k e a яk e k , k
  • 43. я a я ko , k a яk c ei a яk a ( )।কিন্তু e a o । a яk a n ei e a яk e / / (bunch).e g я ei a яk e t я e u e s n ( ei skp ), e c e (bunch) (a яk ), s n e я , p (a яk) я я я m s nt । k ei ( d -Procrdure Oriented way) e (bunch) sk pi । kkkk ( CLASS)( CLASS)( CLASS)( CLASS) ei a яk ei a яk e я e /e l (blueprint/template/outline) e p (e a яk e я ) k । k c a я k я (blueprint).e k c a я k я e e l e e k я , a e k e a яk m e a яk a n ei ei e living,breathing a яk k e u t living,breathing a яk c ei a яk । e se se se s ( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON) e k (class) e e i e e k e k e k i e o a i ei p t ei k i i i ei e i ei e n o p k (data hiding/information hiding) i ni ni ni n ( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE) OOP i n : (reusability) p a e k a k k i sk p e k e k ei k a k k k (super class/base class) k e k /p k (subclass/derived class).extends ei o k e k । яяяя ( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM) e a яk e я e i n я ei p k я । я a kя a kя a kя a k ( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG) e OO Program e e a яk e e e a a e a яk a яk e я ei p k i я a k ।
  • 44. 3. a яka яka яka яk aaaa eieieiei ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a) eeee u ।।।। e ei 5 (PHP5) ei 5 m a яk a n e ei 4 m a яk a n ei 5 a яk a n o e я , , o e p я OOPHP ei , , n s n, i । u я e 23 a ( ) । ---- :::: pppp ei я rei я rei я rei я r index.php class_lib.php a яk a n e i i i ei ‘includes’ ei e я ei u я a яk a n class_lib.php i OOP k я k c m p /k a яk e я a яk m । ---- :::: eeee ei kei kei kei k ei sk p , , i a яk a n d p i e k k я p i ‘class’ b e e k i c । 1.<?php 2.class people{ 3. 4.} 5.?>
  • 45. ---- :::: kkkk k c a я k я b pn/ k e ei ‘property’ 1.<?php 2.class people{ 3.var name; 4.} 5.?> : e k / (ei u var name;) e ‘properties’ ---- :::: kkkk //// e k e ‘properties’ e k e ‘methods’ ( k e ei )e k /methods i k /properties । <?php class people{ var $name; function set_name($new_name){ $this->name=$new_name; } function get_name(){ return $this->name; } } ?>
  • 46. k properties e । ---- :::: gettergettergettergetter eeee settersettersettersetter / get_name() e set_name() ei я e 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 e ei p g a яk я i t set_name() / e a i e property/variable ‘name’ ---- :::: ‘$t hi s$t hi s$t hi s$t hi s’ m i $this->name=$new_name $this e li ( a я ki e l i ) a яk a e e self- referencing e properties e e e e k । function get_name() { return $this->name; }
  • 47. e e e ei o e ei ei ei i я । ---- :::: ei я ei kei я ei kei я ei kei я ei k ei я ei k a яk a n p g e u d i k e ei я ei я e ‘include’ ‘require’ । <!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 ,e । ---- :::: a яka яka яka яk e k a яk p k instantiation. <?php include("class_lib.php"); ?> </head> <body> $rejoan = new people(); </body> </html>
  • 48. $rejoan people a яk e я n $rejoan ei people a яk nt e я । ---- :::: newnewnewnew oooo e k a яk ei new o p я । i c e k a a яk ei i я p a яk (s nt st ) <?php include("class_lib.php"); ?> </head> <body> $rejoan = new people(); $riad = new people; </body> </html> a яk k quote a e $rejoan= new 'people'; ---- :::: a яka яka яka яk propertiespropertiespropertiesproperties ((((setsetsetset)))) ।।।। a яk people ,e properties (set) (the setters) । e o a яk e 2 ($rejoan e $riad) e i k people e u t ei n m a ei e 2 a яk m । <?php include("class_lib.php"); ?> </head> <body> <?php
  • 49. $rejoan = new people(); $riad= new people; $rejoan->set_name("Rejoanul Alam"); $riad->set_name("Anjirul Alam"); ?> </body> </html> ---- :::: a я k ea я k ea я k ea я k e e getter a я k e e i setter a я k । k e properties e e i a (->) h । <?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 (=>) ei h n e । a n ei u a । : e ei k я i ei k u t e я a яk a я k
  • 50. a яk -12: a яka яka яka яk propertiespropertiespropertiesproperties e ee ee ee e ???? eeee a я k properties e e , a (->) a e u s : $rejoan->name. o e o e e e я d e 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 "Rejoan’s full name: " . $rejoan->name; ?> </body> </html> ---- :::: sT ksT ksT ksT k a я k e li s k e a я k properties e । :__construct() ei a __construct / e k e a яk । ‘construct’ n s (__) s k k e k (e ) ei d ।
  • 51. <?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 u k functions=methods variables=properties -14: constructconstructconstructconstruct e a яke a яke a яke a яk e s k ,e people a яk $name property’ u : $rejoan = new people("Rejoanul Alam"); e set_name() e sk p । <?php include("class_lib.php"); ?> </head> <body> <?php $rejoan = new people("Rejoanul Alam"); echo "Rejoan’s full Name: " . $rejoan->get_name(); ?> </body>
  • 52. </html> e e u a яk a n ei e li (mechanism) ei । ---- :::: propertiespropertiespropertiesproperties e e e d ।e e e d ।e e e d ।e e e d । a яk a n p g e e e (encapsulation).e a я k s (properties) e e d । k properties e e d я ‘access modifier’ 3 e - 1. 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 (declare) e ‘public’ ।
  • 53. -16: propertiespropertiespropertiesproperties e e d ।ae e d ।ae e d ।ae e d ।a ---- e property private e i k e । property protected t e i k e p k (derived class/ei k k p o k k properties e e ) ei k e я e i k e p k k । public d i u sk p я e e । <?php include("class_lib.php"); ?> </head> <body> <?php $rejoan = new people("Rejoanul Alam"); echo "Rejoan's full name: " . $rejoan->get_name(); /* $pinn_number private i ei e ,p g i */ echo "Tell me private stuff: " . $rejoan->$pinn_number; ?> </body> </html> ---- :::: e de de de d properties e o ei 3 e e nt । 1. public 2. private 3. protected e ? ut : e e , k a ei p g ei e t e p я k e a ei p g я e i o ।
  • 54. <?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; } } ?> : get_pinn_number() e private i ei t k , k sk p a o ei public । ---- :::: :::: ::::i ni ni ni n a яk a n p g e i n (Inheritence) e d e k a k /k k । e ? ut :e d k : e k c ‘employee’ employee e people/person i e i e properties । e ? ei a s i n e e i : k n e d ei । 1. sk p e i । 2. : c i e a (a ) k n i e i a ei ‘includes()’ e я ।
  • 55. // 'extends' ei o i n class employee extends people { function __construct($employee_name) { } ---- :::: :::: ।a।a।a।a ---- employee k k people i employee k a people k ‘public’ properties, ei k (a ei k )। // 'extends' ei o i n class employee extends people { function __construct($employee_name) { $this->set_name($employee_name); } } k employee k set_name() o ei employee k (declare) i ei i people k । -20: :::: ।a।a।a।a ---- employee a я k get_name() people k я e e d u (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");
  • 56. echo "Riad’s full name " . $riad->get_name(); ?> </body> </html> ---- :::: Over r i ddi ngOver r i ddi ngOver r i ddi ngOver r i ddi ng ( i n ) e k я e p я । u s set_name() people k n employee k । n people k set_name() Override employee k ei e i । <?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 i n class employee extends people { protected function set_name($new_name) { if ($new_name == "Stefan Sucks") { $this->name = $new_name; } }
  • 57. function __construct($employee_name) { $this->set_name($employee_name); } } ?> k set_name() people k ( k ) n employee k । -22: OverridingOverridingOverridingOverriding....aaaa ---- o k e , i k p k (e child k o ) override । u employee k set_name() override e e people::set_name($new_name); e parent k (People) set_name() e । <?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) {
  • 58. 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); } } ?> ---- :::: overridingoverridingoverridingoverriding aaaa ---- 'people::set_name()' e ei i я people k set_name() я । d parent o k parent k ( k parent k ) । <?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
  • 59. 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); } } ?> :::: a яk a n p g e e e OOPHP e я я a я e OOP k d я e e , я a яk e n я e 8/10 e a яk k я । OOPOOPOOPOOP e p ge p ge p ge p g a яk a n p g o e d a я e ei я , ei , , ++ i । o я a яk a n i e я e i o s e p ( o ) o e p (o ) i OOP e u a яk a n ei i i e я । e e e i , ei p я k я p a s e я e я n e s n p яk a яk nd eя a яk p яk g k g - Ø o я । Ø p a яk p яn я k k Ø ei k e properties e Ø a e a яk m (parent-child/base-derived) 4.
  • 60. u T sT uu T sT uu T sT uu T sT u ( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n( MVC St r uct ur e Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo u n s MVC Structure (e я i d ) ei e p я 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 ei m i a a m u n я i ei e ei MVC Structure 3 n я e i e я ei 3 (Model) u (View) n (Controller) ( MODEL) :( MODEL) :( MODEL) :( MODEL) : i i e e p ,ei e p a t (a я ) d i , , i a a s p яn ei я я я (business logic) uuuu ( VI EW) :( VI EW) :( VI EW) :( VI EW) :
  • 61. e s d iuя e я a e e o я ei e e я i i e e я e a o я , , e e я i । TTTT ( CONTROLLER) :( CONTROLLER) :( CONTROLLER) :( CONTROLLER) : n s d e u e я e a a e u я ei я e । i i o MVC a u n s e t я a e e । 5. i i ui i ui i ui i u e i se i se i se i s ( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l( CodeI gni t er Downl oad & I nst al l Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a) : яoяoяoяo p http://codeigniter.com/downloads/e i i o u , e .zip format e e я e o , я c i e c htdocs folder,e ei F:Program Filesxampphtdocs. e C Drive e C
  • 62. drive e F i F c ei C:Program Filesxampphtdocs. e e u (e я ) l a s l CodeIgniter. e i i l e system>>application>> config>>config.php i 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.
  • 63. 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
  • 64. 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. i ii ii ii i ( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) : яoяoяoяo e “config.php” i o database.php e i e e । 01.$active_group = "default"; 02.$active_record = TRUE; 03. 04. 05.$db['default']['hostname'] = "localhost"; 06.$db['default']['username'] = "root"; 07.$db['default']['password'] = "mypassword"; 08.$db['default']['database'] = "mydatabase"; 09.$db['default']['dbdriver'] = "mysql"; 10.$db['default']['dbprefix'] = ""; 11.$db['default']['pconnect'] = TRUE; 12.$db['default']['db_debug'] = TRUE; 13.$db['default']['cache_on'] = FALSE; 14.$db['default']['cachedir'] = ""; 15.$db['default']['char_set'] = "utf8"; 16.$db['default']['dbcollat'] = "utf8_general_ci"; e address bar e http://localhost/CodeIgniter/ en a i s ।
  • 65. 7. i i e p e pi i e p e pi i e p e pi i e p e p ( Cr eat i ng Fi r st( Cr eat i ng Fi r st( Cr eat i ng Fi r st( Cr eat i ng Fi r st Appl i cat i on wi t hAppl i cat i on wi t hAppl i cat i on wi t hAppl i cat i on wi t h CodeI gni t er )CodeI gni t er )CodeI gni t er )CodeI gni t er ) : яoяoяoяo c ei u OOP e OOPHP e u e e a яk a n p g e i i e a u o , p । i i MVC Structure e t ,e o e p я ei d я я ( a ),e p я ( n a )e я я ( u a ) i e e p e e p c ei e p n e u e e я i i e o я i। F:Program FilesxampphtdocsCodeIgnitersystemapplicationcontrollers ei e helloworld.php i (F e я C ) ei i e ++ e e class e 01.<?php 02.class HelloWorld extends Controller{ 03.function HelloWorld(){ 04.// load controller parent 05.parent::Controller();
  • 66. 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 k e c k /p k / k k 'Controller' ei 'Controller' k i i i e c k / n k ei n k 'Controller' extends o k 'HellowWorld' p (derived). e parent::Controller() e function index() d ei c n k (Controller e) o e index() ( ) p $data (a ) e d u p ei n i m p 'helloworld.php'।কোডইগনাইটারে loader e k , n e k i ei loader k a i l e i i ei loader k u i я e $this->load->view('helloworld',$data); e u i e e pass b uя u i e F:Program FilesxampphtdocsCodeIgnitersystemapplicationviews ei helloworld.php e i i 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 : Controller e Views folder e k welcome.php e welcome_message.php i ++ e a ।