SlideShare une entreprise Scribd logo
1  sur  27
Web Server

-Web

server: IIS, Apache
-Script Language: ASP, PHP..
-Database: mysql, mssql…
Operation Principles
What is PHP?

-PHP

stands for PHP: Hypertext Preprocessor.
-PHP is a server-side scripting language, like ASP
-PHP scripts are executed on the server
-PHP supports many databases
(MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
-PHP is an open source software
-PHP is free to download and use
What is a PHP File?

-PHP files can contain text, HTML tags and scripts.
-PHP files are returned to the browser as plain HTML.
-PHP files have a file extension of ".php", ".php3", or
".phtml“.
What is MySQL?
-MySQL is a database server.
-MySQL is ideal for both small and large applications.
-MySQL supports standard SQL.
-MySQL compiles on a number of platforms.
-MySQL is free to download and use.
LAMP

-L:

Linux(Fedora, CentOS, Debian, Ubuntu).
-A: Apache.
-M: Mysql.
-P: PHP.
PHP Syntax
-<?php

echo "Hello World";
?>
-//This is a comment
- /*
This is
a comment
block
*/
PHP Variables

-$var_name

= value;

-<?php

$txt="Hello World!";
$x=16;
?>
- a-z, A-Z, 0-9, and _
PHP String Variables
-<?php

$txt="Hello World";
echo $txt;// Hello World
?>
-<?php
$txt1="Hello World!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
?>
- <?php
echo strlen("Hello
world!");
// 12
?>

-<?php
echo strpos("Hello
world!","world");
//6
?>
PHP Operators
-Arithmetic Operators
-Assignment Operators
-Comparison Operators
-Logical Operators
PHP Operators
(Arithmetic)
PHP Operators
(Assignment )
PHP Operators
(Comparison)
PHP Operators
(Logical)
PHP If...Else Statements
-if

(condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
-<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>
PHP Switch Statement
-switch

(n)

{
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
default:
code to be executed if n is different from both label1 and
label2;
}
PHP Switch Statement(Cont)
<?php
switch ($x)
{
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}
?>
PHP Arrays
Numeric array - An array with a numeric index.
* $cars=array("Saab","Volvo","BMW","Toyota");

Associative array - An array where each ID key is
associated with a value
* $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);

Multidimensional array - An array containing one or more
arrays.
* $families = array
("Griffin"=>array ("Peter","Lois","Megan"),
"Quagmire"=>array("Glenn")
);
PHP Looping - While Loops
while (condition)
{
code to be executed;
}
<?php
$i=1;
while($i<=5)
{
echo "The number is " . $i .
"<br />";
$i++;
}
?>

do
{
code to be executed;
}
while (condition);
<?php
$i=1;
do
{
$i++;
echo "The number is " . $i .
"<br />";
}
while ($i<=5);
?>
PHP Looping - For Loops
foreach ($array as $value)
{
code to be executed;
}
for (init; condition; increment)
{
code to be executed;
}
<?php
for ($i=1; $i<=5; $i++)
{
echo "The number is " . $i . "<br />";
}
?>

<?php
$x=array("one","two","three"
);
foreach ($x as $value)
{
echo $value . "<br />";
}
?>
PHP Functions
function functionName()
{
code to be executed;
}

<?php
function writeName()
{
echo "Kai Jim Refsnes";
}

echo "My name is ";
writeName();
?>

<html>
<body>
<?php
function &add($x,$y)
{
$total=$x+$y;
return $total;
}
echo "1 + 16 = " . add(1,16);
?>

</body>
</html>
PHP Forms and User Input
<html>
<body>

<html>
<body>

<form
action="welcome.php"
method="post">
Name: <input type="text"
name="fname" />
Age: <input type="text"
name="age" />
<input type="submit" />
</form>

Welcome <?php echo
$_POST["fname"]; ?>!<br />
You are <?php echo
$_POST["age"]; ?> years
old.

</body>
</html>

</body>
</html>
PHP $_GET Function
<html>
<body>

<html>
<body>

<form
action="welcome.php"
method=“get">
Name: <input type="text"
name="fname" />
Age: <input type="text"
name="age" />
<input type="submit" />
</form>

Welcome <?php echo
$_GET["fname"]; ?>!<br />
You are <?php echo
$_GET["age"]; ?> years old.

</body>
</html>

http://www.dqn.vn/welcome.
php?fname=Peter&age=37

</body>
</html>
PHP $_POST Function
<html>
<body>

<html>
<body>

<form
action="welcome.php"
method=“post">
Name: <input type="text"
name="fname" />
Age: <input type="text"
name="age" />
<input type="submit" />
</form>

Welcome <?php echo
$_POST["fname"]; ?>!<br />
You are <?php echo
$_POST["age"]; ?> years
old.

</body>
</html>

http://www.dqn.vn/welcome.
php.

</body>
</html>
The PHP $_REQUEST Function

-The

$_REQUEST function can be used to collect form data sent with both
the GET and POST methods.
-Welcome

<?php echo $_REQUEST["fname"]; ?>!<br />
You are <?php echo $_REQUEST["age"]; ?> years old.
PHP With Database

mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result)) {
printf("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
mysql_close();
Contact Us
www.PhpTrainingIndore.in
Voyage Infosystems (p) Ltd.
4/B , Shraddha Shree Ext.
MR-09,Indore 452001, MP , India

Contenu connexe

Plus de Ishan Mishra

Best Off-page-SEO Techniques for 2020
Best Off-page-SEO Techniques for 2020Best Off-page-SEO Techniques for 2020
Best Off-page-SEO Techniques for 2020Ishan Mishra
 
SEO Services Indore, SEO Indore, SEO Company Indore
SEO Services Indore, SEO Indore, SEO Company IndoreSEO Services Indore, SEO Indore, SEO Company Indore
SEO Services Indore, SEO Indore, SEO Company IndoreIshan Mishra
 
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...Ishan Mishra
 
Top 15 personal finance tips in 2015
Top 15 personal finance tips in 2015Top 15 personal finance tips in 2015
Top 15 personal finance tips in 2015Ishan Mishra
 
Buy vs rent 2015 in India | Real Estate Guide 2015 India
Buy vs rent 2015 in India | Real Estate Guide 2015 India Buy vs rent 2015 in India | Real Estate Guide 2015 India
Buy vs rent 2015 in India | Real Estate Guide 2015 India Ishan Mishra
 
AdSense Optimization Tips for increased ad Revenue
AdSense Optimization Tips for increased ad RevenueAdSense Optimization Tips for increased ad Revenue
AdSense Optimization Tips for increased ad RevenueIshan Mishra
 
Online Travel Agency Report on Social Media Habits of Trave
Online Travel Agency Report on Social Media Habits of TraveOnline Travel Agency Report on Social Media Habits of Trave
Online Travel Agency Report on Social Media Habits of TraveIshan Mishra
 
Management lesson from Mahabharat
Management lesson from MahabharatManagement lesson from Mahabharat
Management lesson from MahabharatIshan Mishra
 
Atif Aslam's Biography
Atif Aslam's BiographyAtif Aslam's Biography
Atif Aslam's BiographyIshan Mishra
 
Introduction to "robots.txt
Introduction to "robots.txtIntroduction to "robots.txt
Introduction to "robots.txtIshan Mishra
 
Inbound Marketing Agency India | ISHAN-Tech
Inbound Marketing Agency India  | ISHAN-TechInbound Marketing Agency India  | ISHAN-Tech
Inbound Marketing Agency India | ISHAN-TechIshan Mishra
 
Crystal IT Park Indore IT ccompanies
Crystal IT Park Indore IT ccompaniesCrystal IT Park Indore IT ccompanies
Crystal IT Park Indore IT ccompaniesIshan Mishra
 
Global Management Consulting, Technology and Outsourcing Services from ISHAN...
 Global Management Consulting, Technology and Outsourcing Services from ISHAN... Global Management Consulting, Technology and Outsourcing Services from ISHAN...
Global Management Consulting, Technology and Outsourcing Services from ISHAN...Ishan Mishra
 
ISHAN-TECH Consulting
ISHAN-TECH ConsultingISHAN-TECH Consulting
ISHAN-TECH ConsultingIshan Mishra
 
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...Ishan Mishra
 

Plus de Ishan Mishra (15)

Best Off-page-SEO Techniques for 2020
Best Off-page-SEO Techniques for 2020Best Off-page-SEO Techniques for 2020
Best Off-page-SEO Techniques for 2020
 
SEO Services Indore, SEO Indore, SEO Company Indore
SEO Services Indore, SEO Indore, SEO Company IndoreSEO Services Indore, SEO Indore, SEO Company Indore
SEO Services Indore, SEO Indore, SEO Company Indore
 
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...
ISHANTECH - AN INTERACTIVE MARKETING AGENCY SPECIALIZING IN SEO, PPC, CRO, CV...
 
Top 15 personal finance tips in 2015
Top 15 personal finance tips in 2015Top 15 personal finance tips in 2015
Top 15 personal finance tips in 2015
 
Buy vs rent 2015 in India | Real Estate Guide 2015 India
Buy vs rent 2015 in India | Real Estate Guide 2015 India Buy vs rent 2015 in India | Real Estate Guide 2015 India
Buy vs rent 2015 in India | Real Estate Guide 2015 India
 
AdSense Optimization Tips for increased ad Revenue
AdSense Optimization Tips for increased ad RevenueAdSense Optimization Tips for increased ad Revenue
AdSense Optimization Tips for increased ad Revenue
 
Online Travel Agency Report on Social Media Habits of Trave
Online Travel Agency Report on Social Media Habits of TraveOnline Travel Agency Report on Social Media Habits of Trave
Online Travel Agency Report on Social Media Habits of Trave
 
Management lesson from Mahabharat
Management lesson from MahabharatManagement lesson from Mahabharat
Management lesson from Mahabharat
 
Atif Aslam's Biography
Atif Aslam's BiographyAtif Aslam's Biography
Atif Aslam's Biography
 
Introduction to "robots.txt
Introduction to "robots.txtIntroduction to "robots.txt
Introduction to "robots.txt
 
Inbound Marketing Agency India | ISHAN-Tech
Inbound Marketing Agency India  | ISHAN-TechInbound Marketing Agency India  | ISHAN-Tech
Inbound Marketing Agency India | ISHAN-Tech
 
Crystal IT Park Indore IT ccompanies
Crystal IT Park Indore IT ccompaniesCrystal IT Park Indore IT ccompanies
Crystal IT Park Indore IT ccompanies
 
Global Management Consulting, Technology and Outsourcing Services from ISHAN...
 Global Management Consulting, Technology and Outsourcing Services from ISHAN... Global Management Consulting, Technology and Outsourcing Services from ISHAN...
Global Management Consulting, Technology and Outsourcing Services from ISHAN...
 
ISHAN-TECH Consulting
ISHAN-TECH ConsultingISHAN-TECH Consulting
ISHAN-TECH Consulting
 
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...
Online Marketing Company, Social Media Marketing, Digital Marketing, Indore, ...
 

Dernier

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 

Dernier (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

PHP Training Indore Best Institute

  • 1. Web Server -Web server: IIS, Apache -Script Language: ASP, PHP.. -Database: mysql, mssql…
  • 3. What is PHP? -PHP stands for PHP: Hypertext Preprocessor. -PHP is a server-side scripting language, like ASP -PHP scripts are executed on the server -PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) -PHP is an open source software -PHP is free to download and use
  • 4. What is a PHP File? -PHP files can contain text, HTML tags and scripts. -PHP files are returned to the browser as plain HTML. -PHP files have a file extension of ".php", ".php3", or ".phtml“.
  • 5. What is MySQL? -MySQL is a database server. -MySQL is ideal for both small and large applications. -MySQL supports standard SQL. -MySQL compiles on a number of platforms. -MySQL is free to download and use.
  • 6. LAMP -L: Linux(Fedora, CentOS, Debian, Ubuntu). -A: Apache. -M: Mysql. -P: PHP.
  • 7. PHP Syntax -<?php echo "Hello World"; ?> -//This is a comment - /* This is a comment block */
  • 8. PHP Variables -$var_name = value; -<?php $txt="Hello World!"; $x=16; ?> - a-z, A-Z, 0-9, and _
  • 9. PHP String Variables -<?php $txt="Hello World"; echo $txt;// Hello World ?> -<?php $txt1="Hello World!"; $txt2="What a nice day!"; echo $txt1 . " " . $txt2; ?> - <?php echo strlen("Hello world!"); // 12 ?> -<?php echo strpos("Hello world!","world"); //6 ?>
  • 10. PHP Operators -Arithmetic Operators -Assignment Operators -Comparison Operators -Logical Operators
  • 15. PHP If...Else Statements -if (condition) code to be executed if condition is true; else code to be executed if condition is false; -<?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?>
  • 16. PHP Switch Statement -switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be executed if n=label2; break; default: code to be executed if n is different from both label1 and label2; }
  • 17. PHP Switch Statement(Cont) <?php switch ($x) { case 1: echo "Number 1"; break; case 2: echo "Number 2"; break; case 3: echo "Number 3"; break; default: echo "No number between 1 and 3"; } ?>
  • 18. PHP Arrays Numeric array - An array with a numeric index. * $cars=array("Saab","Volvo","BMW","Toyota"); Associative array - An array where each ID key is associated with a value * $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34); Multidimensional array - An array containing one or more arrays. * $families = array ("Griffin"=>array ("Peter","Lois","Megan"), "Quagmire"=>array("Glenn") );
  • 19. PHP Looping - While Loops while (condition) { code to be executed; } <?php $i=1; while($i<=5) { echo "The number is " . $i . "<br />"; $i++; } ?> do { code to be executed; } while (condition); <?php $i=1; do { $i++; echo "The number is " . $i . "<br />"; } while ($i<=5); ?>
  • 20. PHP Looping - For Loops foreach ($array as $value) { code to be executed; } for (init; condition; increment) { code to be executed; } <?php for ($i=1; $i<=5; $i++) { echo "The number is " . $i . "<br />"; } ?> <?php $x=array("one","two","three" ); foreach ($x as $value) { echo $value . "<br />"; } ?>
  • 21. PHP Functions function functionName() { code to be executed; } <?php function writeName() { echo "Kai Jim Refsnes"; } echo "My name is "; writeName(); ?> <html> <body> <?php function &add($x,$y) { $total=$x+$y; return $total; } echo "1 + 16 = " . add(1,16); ?> </body> </html>
  • 22. PHP Forms and User Input <html> <body> <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html> </body> </html>
  • 23. PHP $_GET Function <html> <body> <html> <body> <form action="welcome.php" method=“get"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> Welcome <?php echo $_GET["fname"]; ?>!<br /> You are <?php echo $_GET["age"]; ?> years old. </body> </html> http://www.dqn.vn/welcome. php?fname=Peter&age=37 </body> </html>
  • 24. PHP $_POST Function <html> <body> <html> <body> <form action="welcome.php" method=“post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html> http://www.dqn.vn/welcome. php. </body> </html>
  • 25. The PHP $_REQUEST Function -The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. -Welcome <?php echo $_REQUEST["fname"]; ?>!<br /> You are <?php echo $_REQUEST["age"]; ?> years old.
  • 26. PHP With Database mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error()); mysql_select_db("mydb"); $result = mysql_query("SELECT id, name FROM mytable"); while ($row = mysql_fetch_array($result)) { printf("ID: %s Name: %s", $row[0], $row[1]); } mysql_free_result($result); mysql_close();
  • 27. Contact Us www.PhpTrainingIndore.in Voyage Infosystems (p) Ltd. 4/B , Shraddha Shree Ext. MR-09,Indore 452001, MP , India