<<

AAA.A...

1. 2. 3. Syntax 4. (Variables) 5. (String) 6. (Operators) 7. 8. (Loop) 9. While 10. For 11. (Array) 12. (Function) 13. PHP 14. $_GET 15. $_POST

BBB.B...

• 111.1... | ( Advanced PHP Tut or i al i n Bangl a) • 222.2... (PHP( PHP Dat e Funct i on TutTut ori al i n Bangl a) • 333.3... (PHP( PHP I ncl ude Funct i on Tut ori al i n Bangl a) • 444.4... ((PHP PHP rrequi eq ui re FunctFuncti i on TutTutori ori al i n Bangl a) • 555.5... (PHP( PHP Fi l e Funct i on TutTut ori al i n Bangl a) • 666.6... (PHP( PHP Fi l e Upl oad TutTut ori al i n Bangl a)a)7777.... (PHP( PHP Cooki e Tut orior i al i n Bangl a) • 888.8... (PHP( PHP Sessi on Tut orior i al i n BanglBangl a) • 999.9... (PHP( PHP ErrorEr r or Handl er Tut ori al i n Bangl a) • 10. (PHP Mai l Funct i on Tut ori al i n Bangl a) • 111111.11 ... (PHP( PHP Fi l tter er TutTutori orior i al i n BanglBangl a)

CCC....

• 111.1... | ( PHP Fr amewor k Tut or i al i n Bangl a) • 222.2... ((OOP OOP & PHP Tut orori i al i n Bangl a) • ((OOPHP OOPHP Tut orori i al i n Bangl a)

• : ::: || : :::666610 || : : 11111515 | | : : 1616232323 • 444.4... (CodeIgni ( CodeI gni tert er Downl oadoad & InstalInstall l TutoriTutorial al iin n Bangl a) • 5. (MVC( MVC St ructr uct ureur e Tut ori al i n Bangl a) • 666.6... (CodeI( CodeI gni t er Conf i guregur e Tut ori al i n Bangl a) • 777.7... (Creat( Cr eat i ng Fi rstr st Appl i cat i on wi t h CodeI gni t er)

AAA.A...

1.1.1. | ( PHP Basi c) : : instruction run ।“ ” handle Process : (Picture,Content etc) (math calculation,file operation etc) HTML ।

(PHP) ?: PHP Hypertext Preprocessor , ,HTML-embedded syntax C,, । (PHP) : .HTML . HTML Form. . C । .

?:?:?:

hosting( ) । - * . PHP -compitable : apache .PHP * . ( ) . : Specialized ।

webcoachbd.com ।।।

2. (PHP I nst al l at i on Tut ori al i n Bangl a) : apache :MySQL, XAMPP.XAMPP http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe । XAMPP - XAMPP Control Panel C C:\Program Files\xampp C:\xampp start click (Apache MySql) ।

Apache MySql http://localhost English ।

( )

3. ( PHP Code Wri t t i ng) : C drive XAMPP htdocs web content ।

www “C:\xampp\htdocs”( : drive “D:\xampp\htdocs”). “mytest.” - http://localhost/mytest.php , ? ? : Net Beans, Dreamweaver , IDE (Integrated Development Environment). ।

4.

( PHP Synt ax Tut ori al i n Bangl a) : extension .php . execute ।

* । * Scripting Block( ) ।

* instruction(code line) । ( / ) mypage.php , htdocs browse save in http://localhost/mypage.php ।

print. : execute , // # /* */ । : , echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; echo "Hello World! "; ।

echo "Hello World!";

?>

, ।

5.

(PHP Vari abl es Tut ori al i n Bangl a) : (Container) String “Hello Bangladesh” integer value 100. ( declare ) , (value) “$” ।

* case sensitive. $a_number and $A_number , । * $variable_name = Value; - 1.

* “Loosely Typed” declare ( ) । : . letter or “_”(under score) ।

. alpha-numeric characters underscores. a-z, A-Z, 0-9, or _ . । . “___”underscore ($my_string) ($myString) ।

6.

(PHP St ri ng Tut ori al i n Bangl a) :

। Career । store , store echo । 1. $my_string echo , store store ।

Double quotes Single quotes , apostrophes । 1. single quotes - echo ‘PHP it\’s neat’ double quotes single quotes । , quotation heredoc , - 1. - *<<< identifier heredoc TEST ।

* ।

* ,(indent) ।


( ) ।

7.

( PHP Oper at or s) : - manipulate .Unary – (operand ) ।

.Binary- ।

.Ternary- । Operator -Arithmetic, Assignment, Comparison Operator etc.

( ASSI GNMENT OPERATOPERATOR)OR) । $my_var = 4; $another_var = $my_var; $my_var $another_var . Operator English Example + Addition 2+4 - Subtraction 6-2 * Multiplication 5*3 / Division 15/3 % Modulus 43%10 01."; 08.echo "Perform subtraction: 6 - 2 = ".$subtraction."
"; 09.echo "Perform multiplication: 5 * 3 = ".$multiplication."
"; 10.echo "Perform division: 15 / 3 = ".$division."
"; 11.echo "Perform modulus: 5 % 2 = " . $modulus ?> -

( COMPARI SON OPERATOROPERATOR)))) Operator relationship Operator statement statement true false. Comparison Operator - $x=4 $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

( STRI NG OPERATOR) -“”, ‘’

ARI THMETI C ASSI GNMENT OPERATOR COMBI NATI ON Programming , $counter=$counter+1; $counter+=1; Pre/Post-Increment Pre/Post-Decrement: , $x++ $x += 1; $x = $x + 1 ।

“-” ।

8.

( PHP Condi t i onal St at ement ) : action feature “Good Morning” “Good evening” Conditional statement ,condition । Conditional statement - *if statement *if…else statement *if…elseif…else statement *Switch statement

* I F STATEMENT if statement execute condition true Have a nice day Saturday । 1.

* I F …ELSE STATEMENT , , if…else statement । 1. condition true Saturday Have a nice day Today is not Saturday.

* I F …ELSEI F …ELSE STATEMENT statement execute । view source print ? 01. 02. 03.=60) 05.echo "First Division"; 06.elseif ($number>=45 and $number<60) 07.echo “Second Division”; 08.elseif($number>=33 and $number<45) 09.echo "Third Division"; 10.else 11.echo “Failed”; 12.?> 13. 14.

9. (PHP Loop Tut ori al i n Bangl a) : । statement execute । - While Loop Do…while Loop For Loop Foreach Loop

10.

While : condition true while execute ।

1.while (condition) 2.{ 3.code to be executed; 4.} condition false condition ,true execute condition : 01. 02. 03."; 08.$i++; 09.} 10.?> 11. 12. i=1. while($i<=5) I - The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 I ? while loop execute ।

DODODO …WHI LE LOOP while loop condition test , , while execute ।

1.Do 2.{ 3.Code to be executed 4.} 5.While(condition); । 01."; 07.} 08.while ($i<=5); 09.?> i=6 ? This is line 6 This line is outside while loop.so it will not repeat. execute execution repeat ? while loop ।

11.

( PHP For Loop) : while , ।

1.for (init; condition; increment) 2.{ 3.code to be executed; 4.} for loop statement expression assignment statement(loop control variable), execution Boolean expression (evaluate) , true false return loop control variable i=1 I I । 1."; 5.} 6.?> Output The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 expression expression , Boolean expression default true - । foreach loop array

12.

(PHP Array Tut ori al i n Bangl a) : single value (container). value’ container value -key index । single variable store - $city1= “Dhaka” $city2= “Chittagong” $city3= “Rajshahi” $city4= “Sylet” $city5= “Khulna” $city6= “Barishal” (series of element) index - 1. variable store , index array’ index/key Dhaka[0],Chittagong[1]… index number 1. ,=> starting index 2 । 1.“Dhaka”, “Chittagong”, “Rajshahi”, “Sylet”, “Khulna”, “Barishal”, “Barishal”); 3.?> index ।

( ASSOCI ATI VE ARRAY) index/key string associative array : 1.32, "rezwan"=>30,"refat"=>34); 3.?>

( MULTI DI MENSI ONAL ARARRAY)RAY) । 1.array("Bangladesh","India","Pakistan"), 4."Europe"=>array("England","France")"Africa"=>array("Kenya", 5."Libya","Somalia")); 6. 7.?>

FOREACH LOOP associative array foreach statement : 1.”; 6.} 7.?> Output Dhaka Chittagong Rajshahi Sylet Khulna Barishal Barishal

13.

( PHP Funct i on) : execution ।

execute ।

1.function functionName() 2.{ 3.code to be executed; 4.} : ।

_ , । simple 01. Output My name is Md.Rejoanul Alam

, PHP variable 01."; 05.} 06. 07.echo "My name is "; 08.writeName("Rejoanul "); 09.echo "My Father's name is "; 10.writeName("Samad"); 11.echo "My brother's name is "; 12.writeName("Anjirul"); 13.?> Output My name is Rejoanul Alam. My Father's name is Samad Alam. My brother's name is Anjirul Alam. 01."; 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! return return statement view source print ? 01.

14.

( PHP For m) : ’ ( ) - $_GET $_POST. । 1.

2.Name: 3.Age: 4. 5.

“welcome.php” method=POST ,Form POST GET. welcome.php 1.Welcome !
2.You are years old. rezwan age 24, Welcome rezwan! You are 24 years old.

15.

$_$_$_GET$_ GET ( PHP $_GET Met hod) : GET character ( URL ) 1.

2.Name: 3.Age: 4. 5.
http://www.w3schools.com/welcome.php?fname=Peter&age=37 welcome.php $_GET Method । 1.Welcome .
2.You are years old!

16.

( PHP $_POST Met hod) : । ( Mb )

Name: Age:
http://www.w3schools.com/welcome.php $_POST Method । Welcome !
You are years old.

GET Method password POST Method ।

BBB.B...

1.1.1. | ( Advanced PHP Tut ori al i n Bangl a) : webcoachbd.com - , , , , ।

2.

(PHP Dat e Funct i on Tut ori al i n Bangl a) :

( PHP DATE FUNCTI ON) / date() view source print ? 1."; 3.echo date("Y.m.d") . "
"; 4.echo date("Y-m-d") 5.?> Output 2009/05/11 2009.05.11 2009-05-11 ।

3.

(PHP( PHP I ncl ude Funct i on Tut orior i al i n Bangl a) : include() ।

Require()- fatal error( ) । Include()- , , (, , ) include , “menu.php” 1.Home 2.Tutorials 3.References 4.Examples 5.About Us 6.Contact Us view source print ? 01. 02. 03.

04. 05.
06.

Welcome to my home page.

07.

Some text.

08. 09.

4.

(PHP requi re Funct i on Tut ori al i n Bangl a) : require() include() । Include() । 01. 02. 03. 04. 08. 09. Error message: Warning: include(wrongFile.php) [function.include]: failed to open stream: No such file or directory in C: \home\website\test.php on line 5

Warning: include() [function.include]: Failed opening 'wrongFile.php' for inclusion (include_path='.;C:\php5\') in C:\home\website\test.php on line 5

Hello World! Notice that the echo statement is executed! This is because a Warning does not stop the script execution. require() Function Now, let's run the same example with the require( ) function. 1. 2. 3. 7. 8. Error message: Warning: require(wrongFile.php) [function.require]: failed to open stream: No such file or directory in C:\home\website\test.php on line 5

Fatal error: require() [function.require]: Failed opening required 'wrongFile.php' (include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5 echo statement

5.

(PHP( PHP Fi l e Funct i on Tut orior i al i n Bangl a) : fopen 1. 2. 3. 6. 7. fopen “welcome.txt” “r” ( ) “r” read only । Modes Description r Read only. Starts at the beginning of the file r+ Read/Write. Starts at the beginning of the file Write only. Opens and clears the contents of file; or creates a new file if it doesn't w exist Read/Write. Opens and clears the contents of file; or creates a new file if w+ exist a Append. Opens and writes to the end of the file or creates a new file if it doesn't exist 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 a lready exists x+ Read/Write. Creates a new file. Returns FALSE and an error if file already exists fopen() function 1. 2. 3. 6. 7.

fclose() function । 1.

ENDENDOFOFOF OF FILE । if (feof($file)) echo "End of file"; ।

LINE BY LINE fgets() function । 01."; 07.} 08.fclose($file); 09.?>

CHARACTER BY CHARACTCHARACTERER fgetc() function ।

। view source print ? 1.

6.

(PHP Fi l e Upl oad Tut ori al i n Bangl a) : 01. 02. 03. 04.

06. 07. 08.
09. 10.
11. 12. action="upload_file.php" method="post" upload_file.php upload_file.php । Upload_file.php 01. 0) 03.{ 04.echo "Error: " . $_FILES["file"]["error"] . "
"; 05.} 06.else 07.{ 08.echo "Upload: " . $_FILES["file"]["name"] . "
"; 09.echo "Type: " . $_FILES["file"]["type"] . "
"; 10.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; 11.echo "Stored in: " . $_FILES["file"]["tmp_name"]; 12.} 13.?> global PHP $_FILES ।

• $_FILES["file"]["name"] – • $_FILES["file"]["type"] - type • $_FILES["file"]["size"] - size • $_FILES["file"]["tmp_name"] temporary copy । .jpeg,.jpg,.gif । 01. 0) 08.{ 09.echo "Error: " . $_FILES["file"]["error"] . "
"; 10.} 11.else 12.{ 13.echo "Upload: " . $_FILES["file"]["name"] . "
"; 14.echo "Type: " . $_FILES["file"]["type"] . "
"; 15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; 16.echo "Stored in: " . $_FILES["file"]["tmp_name"]; 17.} 18.} 19.else 20.{ 21.echo "Invalid file"; 22.} 23.?>

(temporary copy) , 01. 0) 08.{ 09.echo "Return Code: " . $_FILES["file"]["error"] . "
"; 10.} 11.else 12.{ 13.echo "Upload: " . $_FILES["file"]["name"] . "
"; 14.echo "Type: " . $_FILES["file"]["type"] . "
"; 15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; 16.echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
"; 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.?> , move_uploaded_file ।

“upload” ।

7.

(PHP Cooki e Tut ori al i n Bangl a) : ( / )।ধরুন , , ( ) ।

setcookie() function ।

setcookie() function । setcookie(name, value, expiration); namename: , । value: , username(string) last visit(date) expiration : ( ) । visit ignore । 1. 5. 6......

(((RETRIEVE(RETRIEVERETRIEVE)) $_COOKIE variable retrieve । 1. isset "lastVisit" , visit ।

। view source print ? 1.

8.

(PHP Sessi on Tut ori al i n Bangl a) : , , , - unique id (UID) । session_start() tag । 1. 2. 3. 4. 5. 6. 7. ।

$_SESSION । 01. 06. 07. 08. 09. 13. 14. 15. Pageviews=1 page view counter(page ) isset() ‘views’ ‘views’ variable counter ‘views’variable । 01.

( DESTROYI NG A SESSI OON)N)N)N) unset() or the session_destroy() function ] unset() function । 1. session_destroy() function । 1. session_destroy() reset ।

9.

(PHP Error Handl er Tut ori al i n Bangl a) : error handling ( ) । "die()" statements Custom errors and error triggers Error reporting

"""DIE"DIEDIEDIE()"()" । 1. । Warning : fopen(welcome.txt) [function.fopen]: failed to open stream: No such file or directory in C:\webfolder\test.php on line 2 01. । File not found error ।

call (error level and error message) (optionally: file, line-number, and the error context) । error_function(error_level,error_message,error_file,error_line,error_context)

Parameter Description error_level error report level value number error report level । error_message error message । error_file । error_line । error_context (Specifies an array) ।

(( VALUE)

Value Constant Description 2 E_WARNING run-time errors. Execution 8 E_NOTICE Run-time notices. 256 E_USER_ERROR E_ERROR PHP function trigger_error() । 512 E_USER_WARNING Runtime warnings generated by a call to trigger_error( ) 1024 E_USER_NOTICE Runtime warnings generated by a call to trigger_error( ) 4096 E_RECOVERABLE_ERROR Catchable fatal error. 8191 E_ALL errors warnings, level E_STRICT (E_STRICT PHP 6.0 E_ALL )

1.function customError($errno, $errstr) 2.{ 3.echo "Error: [$errno] $errstr
"; 4.echo "Ending Script"; 5.die(); 6.} error handling error level ।

error handler error handler PHP error handler set_error_handler("customError"); error handle , set_error_handler() , error level । 01.Error: [$errno] $errstr"; 06.} 07. 08.//set error handler 09.set_error_handler("customError"); 10. 11.//trigger error 12.echo($test); 13.?> Error: [8] Undefined variable: test

TRIGGER trigger / trigger_error() function test error । 1.1) 4.{ 5.trigger_error("Value must be 1 or below"); 6.} 7.?> Notice : Value must be 1 or below in C:\webfolder\test.php on line 6 error trigger error level trigger । error

• E_USER_ERROR • E_USER_WARNING • E_USER_NOTICE test E_USER_WARNING error error handler । 01.Error: [$errno] $errstr
"; 06.echo "Ending Script"; 07.die(); 08.} 09. 10.//set error handler 11.set_error_handler("customError",E_USER_WARNING); 12. 13.//trigger error 14.$test=2; 15.if ($test>1) 16.{ 17.trigger_error("Value must be 1 or below",E_USER_WARNING); 18.} 19.?> Error: [512] Value must be 1 or below Ending Script

PHP error_log() error log( ) ।

Error: [$errno] $errstr
"; echo "Webmaster has been notified"; error_log("Error: [$errno] $errstr",1, " [email protected] ","From: [email protected] "); }

//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); } ?> Error: [512] Value must be 1 or below Webmaster has been notified Error: [512] Value must be 1 or below

10.

(PHP Fi l t er Tut ori al i n Bangl a) : (validate/acceptable) (filter) filter -

• • • • •

filter -

• filter_var() – filter ।

• filter_var_array() – । • filter_input – • filter_input_array – । • filter_var() function validate 01. "FILTER_VALIDATE_INT" $int , "Integer is valid" 123 integer.

VALIDATING SANI TI ZI NG

VALI DATI NG FI LTERS:

• user input validate • ( URL E-Mail validating)

SANI TI ZI NG FI LTERS:

• ।

• return ।

OPTIONS FLAGS Option Flag filtering option option flag validate filter_var() "min_range" "max_range" option । 01.array 06.( 07."min_range"=> 0, 08."max_range"=>256 09.) 10.); 11. 12.if(!filter_var($var, FILTER_VALIDATE_INT,$int_options)) 13.{ 14.echo("Integer is not valid"); 15.} 16.else 17.{ 18.echo("Integer is valid"); 19.} 20.?> options associative array “options’’ flag "Integer is not valid".

VALI DATE I NPUT filter_input() function 01. : ( ) "GET" method ।

. "email" GET ।

. ।

SANI TI ZE I NPUT filter_input() function sanitize 01. : (url) "POST" method ।

. "url" POST । . sanitize( ) $url variable । "http://www.W3ååSchøøools.com/ " $url variable sanitizing । http://www.W3Schools.com/

call filter filter_var_array the filter_input_array function view source print ? 01. array 05.( 06."filter"=>FILTER_SANITIZE_STRING 07.), 08."age" => array 09.( 10."filter"=>FILTER_VALIDATE_INT, 11."options"=>array 12.( 13."min_range"=>1, 14."max_range"=>120 15.) 16.), 17."email"=> FILTER_VALIDATE_EMAIL, 18.); 19. 20.$result = filter_input_array(INPUT_GET,$filters); 21. 22.if (!$result["age"]) 23.{ 24.echo("Age must be a number between 1 and 120.
"); 25.} 26.elseif(!$result["email"]) 27.{ 28.echo("E-Mail is not valid.
"); 29.} 30.else 31.{ 32.echo("User input is valid"); 33.} 34.?>

11.

(PHP Mai l Funct i on Tut ori al i n Bangl a)

:

PHP mail() । 1.mail(to,subject,message,headers,parameters)

to । ।

subject । ।

message । । (\n)

headers । । :From,Cc,Bcc .

parameters । ।

: php.ini >> ? - । ( [email protected] )

PHP MAI L FORM

Email:
Subject:
Message:

"; } ?>

::: HTML logic । reload ।

:::: । form validationvalidation.... PHP (((Filter )

CCC.C...

1.1.1. | ( PHP Fr amewor k Tut or i al i n Bangl a) : • (PHP Framework) basic Platform/structure( ) । • , like (like) , । • PHP Framework - , , । • , , ।

(PHP Framework) । (PHP Framework) .PHP( PHP Function, Variable etc) .Object Oriented Programming .MVC(Model View Controller)Structure

, , , - , (CodeIgniter PHP Framework) ।

2.

( OOP & PHP Tut or i al i n Bangl a) : POP ( PROCEDURE ORI ENENTEDTED PROGRAMMI NG) language FORTRAN(Formula Translation- Statistician )COBOL,C Procedure Oriented Programming(POP).PHP POP (instruction/actions) , , + । POP global data ।

OOP( OBJECT ORI ENTED PROGRAMMINGPROGRAMMING)))) OOP (Object Oriented Programming) OOP critical element (free flow) OOP Objects , / / /(interact)

OOP * ( operate ) * Object Object * Object , (Operate ) * ।

* Object Object ।

* । OOP

• Objects • Class • Encapsulation • Inheritence • Polymorphism • Message passing

( OBJECTS) , ( ) (a bundle) , , ( )।কিন্তু । / / (bunch). ( ), (bunch) ( ), , ( ) । ( -Procrdure Oriented way) (bunch) ।

( CLASS) / (blueprint/template/outline) ( ) । (blueprint). , living,breathing living,breathing ।

( ENCAPSULATI ON) (class) (data hiding/information hiding)

( I NHERI TANCE) OOP : (reusability) (super class/base class) / (subclass/derived class).extends ।

( POLYMORPHI SM) ।

( MESSAGE PASSI NG) OO Program ।

3.

( OOPHP Tut or i al i n Bangl a)

। (PHP5) , , OOPHP , , , ।

( ) ।

:::

index.php class_lib.php ‘includes’ class_lib.php OOP / ।

:::

, , ‘class’ । 1.

2.class people{

3.

4.}

5.?>

:::

/ ‘property’ 1.

2.class people{

3.var name;

4.}

5.?>

: / ( var name;) ‘properties’

:::

////

‘properties’ ‘methods’ ( ) /methods /properties ।

name=$new_name; } function get_name(){ return $this->name; } } ?> properties ।

::: getter setter

/ get_name() set_name() getter setter property ।

name=$new_name; } function get_name(){ return $this->name; } } ?> getter setter property set_name() / property/variable ‘name’

:::

‘$t hi s ’

$this->name=$new_name

$this ( ) self- referencing properties । function get_name() { return $this->name; } ।

:::

‘include’ ‘require’ ।

OOPHP in Webcoachbd

, ।

:::

instantiation.

$rejoan = new people();

$rejoan people $rejoan people ।

::: new

new । ( )

$rejoan = new people(); $riad = new people;

quote

$rejoan= new 'people';

:

properties (((set(setset)) ।

people , properties (set) (the setters) । ($rejoan $riad) people । set_name("Rejoanul Alam"); $riad->set_name("Anjirul Alam"); ?>

:

getter setter ।

properties (->) ।

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(); ?>

: (->) (=>) ।

। :

- :

properties ??

properties , (->) :

$rejoan->name.

getter ।

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; ?>

:

properties । :__construct() __construct / । ‘construct’ (__) ( ) ।

name = $people_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?>

functions=methods variables=properties

- : construct

, people $name property’ :

$rejoan = new people("Rejoanul Alam");

set_name() ।

get_name(); ?>

(mechanism) ।

: properties ।

(encapsulation). (properties) । properties ‘access modifier’ - 1. public 2. private 3. protected public ।

name = $people_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?>

: ‘var’ properties (declare) ‘public’ ।

- : properties ।।

property private । property protected (derived class/ properties ) । public ।

get_name(); /* $pinn_number private , */ echo "Tell me private stuff: " . $rejoan->$pinn_number; ?>

:

properties । 1. public 2. private 3. protected ? : , ।

name = $people_name; } private function get_pinn_number() { return $this->$pinn_number; } } ?>

: get_pinn_number() private , public ।

:

::::::::

(Inheritence) / । ? : : ‘employee’ employee people/person properties । ? : ।

. । . : ( ) ‘includes()’ ।

// 'extends' class employee extends people { function __construct($employee_name) { }

:

: :::।।।

employee people employee people ‘public’ properties, ( )।

// 'extends' class employee extends people { function __construct($employee_name) { $this->set_name($employee_name); } }

employee set_name() employee (declare) people ।

- :

::::।।।

employee get_name() people ( / )

OOPHP in Webcoachbd get_name(); $riad = new employee("Anjirul Alam"); echo "Riad’s full name " . $riad->get_name(); ?>

:

OverOverri r i ddi ng

( ) ।

set_name() people employee । people set_name() Override employee ।

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' 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); } } ?>

set_name() people ( ) employee ।

- :

OverridingOverriding....

, ( child ) override । employee set_name() override people::set_name($new_name); parent (People) set_name() ।

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); } } ?>

:

overriding

'people::set_name()' people set_name() । parent parent ( parent ) ।

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); } } ?>

:::: OOPHP OOP , / ।

OOP , , , ++ । ( ) ( ) OOP । , - Ø । Ø Ø properties Ø (parent-child/base-derived)

4. (MVC St ruct ure Tut ori al i n Bangl a) : MVC Structure ( ) 01. 07. 08.

Home Page

09. 13. 14. 17. 18. 19. 20. 21. 24.
25.

MVC Structure (Model) (View) (Controller)

( MODEL) : , ( ) , , (business logic)

( VI EW): , , ।

( CONTROLLER) : । MVC ।

5. (CodeI( CodeI gni t er Downl oad & I nst al l TutTutori ori al i n Bangl a) : http://codeigniter.com/downloads/ , .zip format , htdocs folder, F:\Program Files\xampp\htdocs. C Drive C drive F F C:\Program Files\xampp\htdocs. ( ) CodeIgniter. system>>application>> config>>config.php । 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. (CodeI( CodeI gni t er Conf i guregur e Tut ori al i n Bangl a) : “config.php” database.php । 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"; address bar http://localhost/CodeIgniter/ ।

7. (Creat( Cr eat i ng Fi rstr st Appl i cat i on wi t h CodeI gni t erer) ) : OOP OOPHP , । MVC Structure , ( ), ( ) ( ) । F:\Program Files\xampp\htdocs\CodeIgniter\system\application\controllers helloworld.php (F C ) ++ class 01.load->view('helloworld',$data); 12.} 13.} 14.?> : / / 'Controller' 'Controller' / 'Controller' extends 'HellowWorld' (derived). parent::Controller() function index() (Controller ) index() ( ) $data ( ) 'helloworld.php' ।কোডইগনাইটারে loader , loader loader $this->load->view('helloworld',$data); pass F:\Program Files\xampp\htdocs\CodeIgniter\system\application\views helloworld.php 1. 2. 3.<?php echo $title;?> 4. 5. 6.

7. 8. Address bar । http://localhost/CodeIgniter/index.php/helloworld : Controller Views folder welcome.php welcome_message.php ++ ।