尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Server-Side Scripting
CIVE-IPT 2014 Day 8
Presented by Deo Shao
Server-Side Scripting
• In order to generate dynamic pages we use a server-
side scripting language.
• There are different types of server-side scripting
languages such as PHP, ASP,ASP.NET, ColdFusion, JSP,
Perl and others.
• Each scripting languages is being interpreted by an
application.
• The application which interprets the server-side
script is installed on the sever just like any other
application.
• PHP uses apache which comes with XAMPP & WAMP
Server-Side Scripting
• Server-side scripting languages are also operating
systems dependent.
• Each server-side scripting languages supports
basic programming concepts such as variables,
arrays, functions, loops, conditional statement and
others.
• They also contain more specific elements such as
special objects, commands used to communicate
with the server and a database and much more.
Server-Side Scripting
• When there is a need to store and retrieve
information (user names, items in stock etc.) a
database will be used to contain the data.
• Sever-side script can communicate to a database
using a structured query language (SQL) which
manipulates the database (add, remove, update
etc.)
• More on that next week.
Three Tier Web
Applications
PHP - Hypertext Preprocessor
In 1994 he created
the PHP scripting language,
authoring the first two
versions of the language
Some really large PHP websites
• Facebook
• Wikipedia
• Flickr
• Yahoo! Answers
• Yahoo! Bookmarks
• SourceForge
• Photobucket
• YouTube
Rasmus Lerdorf
(born 22 November 1968)
Basic PHP Syntax
• You cannot view the PHP source code by selecting
"View source" in the browser – you will only see
the output from the PHP file, which is plain HTML.
• This is because the scripts are executed on the
server before the result is sent back to the
browser.
• A PHP scripting block always starts with <?php and
ends with ?>.
• A PHP scripting block can be placed anywhere in
the document.
Basic PHP Syntax
• On servers with shorthand support enabled you
can start a scripting block with <?
• and end with ?>.
• However, for maximum compatibility, we
recommend that you use the standard form
(<?php) rather than the shorthand form.
• A PHP file normally contains HTML tags, just like
an HTML file, and some PHP scripting code.
Basic PHP Syntax
• Each code line in PHP must end with a semicolon.
The semicolon is a separator and
• is used to distinguish one set of instructions from
another.
• There are two basic statements to output text
with PHP: echo and print. In the
• example above we have used the echo statement
to output the text "Hello World".
PHP Variables
• Variables are used for storing a values, like text
strings, numbers or arrays.
• When a variable is set it can be used over and
over again in your script
• All variables in PHP start with a $ sign symbol.
• The correct way of setting a variable in PHP:
$var_name = value;
PHP Variables
• In PHP a variable does not need to be declared
before being set.
• In the previous example, you see that you do not
have to tell PHP which data type the variable is.
• PHP automatically converts the variable to the
correct data type, depending on how they are
set.
• In a strongly typed programming language, you
have to declare (define) the type and name of
the variable before using it.
• In PHP the variable is declared automatically
when you use it.
PHP Variables
• A variable name must start with a letter or an
underscore "_"
• A variable name can only contain alpha-numeric
characters and underscores (a-Z, 0-9, and _ )
• A variable name should not contain spaces.
• If a variable name is more than one word, it
should be separated with underscore
($my_string), or with capitalization ($myString)
Conditional Statements
• Very often when you write code, you want to
perform different actions for different decisions.
• You can use conditional statements in your code
to do this.
If (condition)
…code1
Else
…code 2
The Switch Statement - Syntax
• If you want to select one of many blocks of code
to be executed, use the Switch statement.
• The switch statement is used to avoid long blocks
of if..elseif..else code.
The Switch Statement - Syntax
switch (expression)
{
case label1:
code to be executed if expression = label1;
break;
case label2:
code to be executed if expression = label2;
break;
default:
code to be executed if expression is different from both
label1 and label2;
}
The For loop- Syntax
for(initialization; test_condition;loop_update)
{
statement(s)
}
• The test_condition uses relational and logical
operators (<,>,>=,<, &&, ||, etc).
• It is checked at the end of each iteration of the
loop.
• If the condition is still true then another iteration
of the loop is undertaken
The While Loop -Syntax
while (condition=TRUE)
{
statement(s)
}
• The lines of code within {} brackets are repeated as
long as the condition specified in the while statement
is TRUE.
• The condition is checked BEFORE each iteration of
the loop.
• The actual condition can be a single condition or a
logical combination of individual conditions (using
logical operators - &&, || or !).
The Do While Loop - Syntax
do
{
//statement(s);
} while (condition=TRUE);
• Statement(s) is/are executed, and condition is
evaluated if the value of condition is TRUE, then control
passes back to the beginning of the do statement, and
the process repeats itself.
• When condition is FALSE, then control passes to next
statement bellow the loop block.

More Related Content

What's hot

Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
Gtu Booker
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
webhostingguy
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
vishal choudhary
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
nhepner
 
Php introduction
Php introductionPhp introduction
Php introduction
krishnapriya Tadepalli
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
casestudyhelp
 
PHP
PHPPHP
Jquery
JqueryJquery
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
Raghuveer Guthikonda
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
Rajiv Bhatia
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
FaysalAhammed5
 
Php essentials
Php essentialsPhp essentials
Php essentials
sagaroceanic11
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
C# operators
C# operatorsC# operators
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
Dominic Arrojado
 

What's hot (20)

Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
PHP
PHPPHP
PHP
 
Jquery
JqueryJquery
Jquery
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
Php essentials
Php essentialsPhp essentials
Php essentials
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
C# operators
C# operatorsC# operators
C# operators
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 

Similar to Server Scripting Language -PHP

PPT 19.pptx
PPT 19.pptxPPT 19.pptx
PPT 19.pptx
DrRavneetSingh
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
Robby Firmansyah
 
php basic part one
php basic part onephp basic part one
php basic part one
jeweltutin
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
MacSila
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
jeeva indra
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
HambaAbebe2
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
Amirul Shafeeq
 
Php Basics
Php BasicsPhp Basics
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
pratik tambekar
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
php basics
php basicsphp basics
php basics
Anmol Paul
 
PHP Basic & Variables
PHP Basic & VariablesPHP Basic & Variables
PHP Basic & Variables
M.Zalmai Rahmani
 
Introduction to php contains basic....pptx
Introduction to php contains basic....pptxIntroduction to php contains basic....pptx
Introduction to php contains basic....pptx
RanjithaGowda63
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
PrinceGuru MS
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Php basics
Php basicsPhp basics
Php basics
Jamshid Hashimi
 

Similar to Server Scripting Language -PHP (20)

PPT 19.pptx
PPT 19.pptxPPT 19.pptx
PPT 19.pptx
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
php basic part one
php basic part onephp basic part one
php basic part one
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
 
Php Basics
Php BasicsPhp Basics
Php Basics
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
php basics
php basicsphp basics
php basics
 
PHP Basic & Variables
PHP Basic & VariablesPHP Basic & Variables
PHP Basic & Variables
 
Introduction to php contains basic....pptx
Introduction to php contains basic....pptxIntroduction to php contains basic....pptx
Introduction to php contains basic....pptx
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Php basics
Php basicsPhp basics
Php basics
 

Recently uploaded

Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
MJDuyan
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
MJDuyan
 
Talking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual AidsTalking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual Aids
MattVassar1
 
The Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptxThe Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptx
PriyaKumari928991
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
Celine George
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
Frederic Fovet
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
Infosec
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
Celine George
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
whatchangedhowreflec
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
Kalna College
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
Nguyen Thanh Tu Collection
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
Kalna College
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
Sarojini38
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
MattVassar1
 
A Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by QuizzitoA Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by Quizzito
Quizzito The Quiz Society of Gargi College
 

Recently uploaded (20)

Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
 
Talking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual AidsTalking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual Aids
 
The Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptxThe Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptx
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
 
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
 
A Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by QuizzitoA Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by Quizzito
 

Server Scripting Language -PHP

  • 1. Server-Side Scripting CIVE-IPT 2014 Day 8 Presented by Deo Shao
  • 2. Server-Side Scripting • In order to generate dynamic pages we use a server- side scripting language. • There are different types of server-side scripting languages such as PHP, ASP,ASP.NET, ColdFusion, JSP, Perl and others. • Each scripting languages is being interpreted by an application. • The application which interprets the server-side script is installed on the sever just like any other application. • PHP uses apache which comes with XAMPP & WAMP
  • 3. Server-Side Scripting • Server-side scripting languages are also operating systems dependent. • Each server-side scripting languages supports basic programming concepts such as variables, arrays, functions, loops, conditional statement and others. • They also contain more specific elements such as special objects, commands used to communicate with the server and a database and much more.
  • 4. Server-Side Scripting • When there is a need to store and retrieve information (user names, items in stock etc.) a database will be used to contain the data. • Sever-side script can communicate to a database using a structured query language (SQL) which manipulates the database (add, remove, update etc.) • More on that next week.
  • 6. PHP - Hypertext Preprocessor In 1994 he created the PHP scripting language, authoring the first two versions of the language Some really large PHP websites • Facebook • Wikipedia • Flickr • Yahoo! Answers • Yahoo! Bookmarks • SourceForge • Photobucket • YouTube Rasmus Lerdorf (born 22 November 1968)
  • 7. Basic PHP Syntax • You cannot view the PHP source code by selecting "View source" in the browser – you will only see the output from the PHP file, which is plain HTML. • This is because the scripts are executed on the server before the result is sent back to the browser. • A PHP scripting block always starts with <?php and ends with ?>. • A PHP scripting block can be placed anywhere in the document.
  • 8. Basic PHP Syntax • On servers with shorthand support enabled you can start a scripting block with <? • and end with ?>. • However, for maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form. • A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
  • 9. Basic PHP Syntax • Each code line in PHP must end with a semicolon. The semicolon is a separator and • is used to distinguish one set of instructions from another. • There are two basic statements to output text with PHP: echo and print. In the • example above we have used the echo statement to output the text "Hello World".
  • 10. PHP Variables • Variables are used for storing a values, like text strings, numbers or arrays. • When a variable is set it can be used over and over again in your script • All variables in PHP start with a $ sign symbol. • The correct way of setting a variable in PHP: $var_name = value;
  • 11. PHP Variables • In PHP a variable does not need to be declared before being set. • In the previous example, you see that you do not have to tell PHP which data type the variable is. • PHP automatically converts the variable to the correct data type, depending on how they are set. • In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it. • In PHP the variable is declared automatically when you use it.
  • 12. PHP Variables • A variable name must start with a letter or an underscore "_" • A variable name can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ ) • A variable name should not contain spaces. • If a variable name is more than one word, it should be separated with underscore ($my_string), or with capitalization ($myString)
  • 13. Conditional Statements • Very often when you write code, you want to perform different actions for different decisions. • You can use conditional statements in your code to do this. If (condition) …code1 Else …code 2
  • 14. The Switch Statement - Syntax • If you want to select one of many blocks of code to be executed, use the Switch statement. • The switch statement is used to avoid long blocks of if..elseif..else code.
  • 15. The Switch Statement - Syntax switch (expression) { case label1: code to be executed if expression = label1; break; case label2: code to be executed if expression = label2; break; default: code to be executed if expression is different from both label1 and label2; }
  • 16. The For loop- Syntax for(initialization; test_condition;loop_update) { statement(s) } • The test_condition uses relational and logical operators (<,>,>=,<, &&, ||, etc). • It is checked at the end of each iteration of the loop. • If the condition is still true then another iteration of the loop is undertaken
  • 17. The While Loop -Syntax while (condition=TRUE) { statement(s) } • The lines of code within {} brackets are repeated as long as the condition specified in the while statement is TRUE. • The condition is checked BEFORE each iteration of the loop. • The actual condition can be a single condition or a logical combination of individual conditions (using logical operators - &&, || or !).
  • 18. The Do While Loop - Syntax do { //statement(s); } while (condition=TRUE); • Statement(s) is/are executed, and condition is evaluated if the value of condition is TRUE, then control passes back to the beginning of the do statement, and the process repeats itself. • When condition is FALSE, then control passes to next statement bellow the loop block.
  翻译: