SlideShare a Scribd company logo
Php   a dynamic web scripting language
P - PHP
H - Hypertext
P - Preprocessor
 PHP is an acronym for “PHP
Hypertext Preprocessor”. (Originally,
„Personal Home Page’). It was
created by Rasmus Lerdorf in 1995 to
maintain his personal home page
 PHP is a widely-used server scripting
language, and is a powerful tool for
making dynamic and interactive
web pages quickly
 PHP is an object-oriented
programming language, which
means that you can create objects,
which can contain variables and
functions
 PHP scripts are executed on the server
 PHP is an open source software
 PHP costs nothing, it is free to
download and use
PHP files can contain text, HTML,
CSS, JavaScript and PHP code
PHP files are executed on the
server and the result are returned
to the browser as plain HTML
PHP files have extension “.php”
To start using PHP, you can:
Find a web host with PHP and
MySQL Support
Install a web server on your own
PC, and then install PHP and
MySQL
Visit www.php.net for free download.
Download XAMPP installer
XAMPP is an all-in-one installer
package of local server, MySql
and PHP
* Take a look at this video on how to install XAMPP
Php   a dynamic web scripting language
1. Go to XAMPP directory folder
located in local disk C: & open it
2. Click the “htdocs” folder
3. Create your own folder inside
that „htdocs’
4. Put/save all your PHP Files inside
your own folder
*Remember: Never rename or delete any default folder/s
inside XAMPP directory except that of your own folder
*Take the ff. steps every time you want to
test/run your PHP files?
1. Open XAMPP Control Panel
2. Click the „Start‟ button of the Apache
Server and of the MySQL if your PHP has a
database
3. Open any web browser (Chrome,
IE,Firefox, Safari etc)
4. Type in the address bar
“localhost/yourfoldername” & press Enter
button
<?php
//php code goes here
?>
.php
Example: myfirstproject.php
File Name File Extension
<html>
<body>
<?php
echo "Hello World";
print “Hello World”;
?>
</body>
</html>
Example:
There are two basic statements to
output or send text to the browser:
echo or print
Example:
echo "Hello World";
print “Hello World”;
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.
<html>
<body>
<?php
//This is a single line comment
# This is also a single line comment
/*
This is a multiple lines comment
block that spans over more than one line
*/
?>
</body>
</html>
Variables are “containers” for storing information. It
can store values like text strings, numbers or
arrays.
Rules for PHP variables:
 A variable starts with a $ (sigil) sign, followed by the
name of the variable.
 A variable name must start with a letter or the underscore
character
 A variable name cannot start with a number
 A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _)
 Variable names are case sensitive ($y and $Y are two
different variables)
The correct way of declaring a variable in PHP:
$var_name = value;
Example:
<?php
$text="Hello Math!";
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>
Remember: (put quotes for text variable’s value)
(no quotes needed for number variable’s value)
 All user-defined functions, classes, and keywords
(e.g. if, else, while, echo, etc.) are case-
insensitive
Example 1:
<?php
EcHo “Hello World!”;
echo “Hello World!”;
ECHO “Hello World!”;
?>
all three echo
statements are
legal (and
equal)
 All variables are case-sensitive
Example:
<?php
$color=”red”;
echo “My car is “ . $color;
echo “My car is “ . $COLOR;
echo “My car is “ . $coLOR;
?>
only the first
statement will
display the
value of the
$color variable
( .) – Concatenator
The concatenation operator (.) is used to
put two string values together.
Example:
<?php
$txt1="Hello World!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
?>
The output of the code above will be:
Hello World! What a nice day!
Operators are used to operate on values.
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
+ - * / % ++ --
= += -= *= /= .= %=
== != <> > < >= <=
&& and
II or
! not
Conditional Statements
The if...else Statement
Use the if....else statement to execute some code if a
condition is true and another code if a condition is false.
 Syntax
if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
The if...else Statement
Example:
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>
</body>
</html>
Conditional Statements
The if...elseif....else Statement
Use the if....elseif...else statement to select one of several
blocks of code to be executed.
 Syntax
if (condition)
code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
The if...elseif....else Statement
Example:
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>
Conditional statements are used to perform
different actions based on different conditions.
 Syntax
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;
}
Example:
<?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 $_POST Function
The built-in „$_POST‟ function is
used to collect values in a form
with method="post".
PHP $_POST Function
Example:
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
When the user clicks the "Submit" button, the
"welcome.php" file can now use the $_POST function to
collect form data
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
Output could be something like this:
Welcome John!
You are 28 years old.
Problem:
How to create a program that
inputs „student name‟,
„attendance grade‟, „quiz grade‟,
„project grade‟, & „major exam
grade‟ with an output of student
name, total grade and remarks
using PHP?
<html>
<body>
<h1> Student Grade:</h1>
<form action="compute.php" method="post">
Student Name:<input type="text" name="sname" />
<br>
Attendance Grade:<input type="text" name="agrade" />
<br>
Quiz Grade:<input type="text" name="qgrade" />
<br>
Project Grade: <input type="text" name="pgrade" />
<br>
Major Exam Grade:<input type="text" name="egrade" />
<br>
<input type="submit" value="Compute"/>
</form>
</body>
Create this first
file and Save
this as
studentgrade.
php
PHP file #1
<html>
<body>
<?php
echo $_POST["sname"];
?>
<br>
<?php
$attgrade = $_POST['agrade'];
$quizgrade = $_POST['qgrade'];
$prograde = $_POST['pgrade'];
$megrade = $_POST['egrade'];
$total = ($attgrade * 0.10) + ($quizgrade * 0.15) + ($prograde * 0.25)
+ ($megrade * 0.50);
?>
<br>
PHP file #2
<?php
echo 'Total Grade:' . $total;
?>
<br>
<?php
if ($total >= 75) {
echo "Remarks: Passed!";
}
else {
echo "Remarks: Failed!";
}
?>
</body>
</html>
Create this
second file
and Save this
as
compute.php
and run/test
the two files
Save this file as
compute.php
INPUT OUTPUT
THANK YOU!

More Related Content

PPTX
Php basics
PPT
Introduction to php
PPT
Control Structures In Php 2
PPT
PPT
What Is Php
 
PPT
PDF
Introduction to php
Php basics
Introduction to php
Control Structures In Php 2
What Is Php
 
Introduction to php

What's hot (20)

PPTX
PPTX
Php Unit 1
PPTX
Constructor and encapsulation in php
PPT
Chapter 02 php basic syntax
PPT
PHP Tutorials
PPTX
Php.ppt
PDF
Php introduction
PPTX
PHP slides
PPSX
PHP Comprehensive Overview
PPTX
Dev traning 2016 basics of PHP
PPT
Php Lecture Notes
PPTX
Php Tutorial
PPT
PHP MySQL Workshop - facehook
PPTX
PPT
PHP Workshop Notes
PPT
PHP complete reference with database concepts for beginners
PPT
PHP - Introduction to PHP Fundamentals
PPTX
php basics
PPTX
Basic of PHP
Php Unit 1
Constructor and encapsulation in php
Chapter 02 php basic syntax
PHP Tutorials
Php.ppt
Php introduction
PHP slides
PHP Comprehensive Overview
Dev traning 2016 basics of PHP
Php Lecture Notes
Php Tutorial
PHP MySQL Workshop - facehook
PHP Workshop Notes
PHP complete reference with database concepts for beginners
PHP - Introduction to PHP Fundamentals
php basics
Basic of PHP
Ad

Viewers also liked (16)

PDF
Pgdca final syllabus_2007_revised_31st_july_2007
DOCX
Computer basic course
DOCX
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
PDF
Router components in hindi
PDF
Pagemaker hindi notes
PDF
C language in hindi (cलेग्वेज इन हिंदी )
PPT
Introduction To PHP
PPTX
PHP Powerpoint -- Teach PHP with this
PDF
Computer netwoking notes & qustionspart 2
PDF
Photoshop hindi-notes
PDF
Networking in hindi notes
PDF
Excel shortcut and function keys hindi notes
PDF
Internet notes hindi
PDF
Introduction of Internet Hindi Notes
PDF
Microsoft office hindi notes
PDF
Corel draw 14 hindi notes
Pgdca final syllabus_2007_revised_31st_july_2007
Computer basic course
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
Router components in hindi
Pagemaker hindi notes
C language in hindi (cलेग्वेज इन हिंदी )
Introduction To PHP
PHP Powerpoint -- Teach PHP with this
Computer netwoking notes & qustionspart 2
Photoshop hindi-notes
Networking in hindi notes
Excel shortcut and function keys hindi notes
Internet notes hindi
Introduction of Internet Hindi Notes
Microsoft office hindi notes
Corel draw 14 hindi notes
Ad

Similar to Php a dynamic web scripting language (20)

DOCX
Basic php 5
PPTX
Day1
PPTX
Php by shivitomer
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
PPTX
Introduction to php
DOCX
PHP NOTES FOR BEGGINERS
PDF
WT_PHP_PART1.pdf
PPTX
The basics of php for engeneering students
PDF
Web Development Course: PHP lecture 1
PPSX
Php and MySQL
DOCX
Free PHP Book Online | PHP Development in India
PDF
Introduction to PHP - Basics of PHP
PPT
Php Tutorial
PPT
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
PPT
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
PPT
Php i basic chapter 3
PDF
basic concept of php(Gunikhan sonowal)
PPTX
Intro to php
PPTX
PHP.pptx is the Best Explanation of ppts
Basic php 5
Day1
Php by shivitomer
FYBSC IT Web Programming Unit IV PHP and MySQL
Introduction to php
PHP NOTES FOR BEGGINERS
WT_PHP_PART1.pdf
The basics of php for engeneering students
Web Development Course: PHP lecture 1
Php and MySQL
Free PHP Book Online | PHP Development in India
Introduction to PHP - Basics of PHP
Php Tutorial
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3
basic concept of php(Gunikhan sonowal)
Intro to php
PHP.pptx is the Best Explanation of ppts

Recently uploaded (20)

PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Essential Infomation Tech presentation.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
L1 - Introduction to python Backend.pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
ai tools demonstartion for schools and inter college
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
medical staffing services at VALiNTRY
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
How Creative Agencies Leverage Project Management Software.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Essential Infomation Tech presentation.pptx
Design an Analysis of Algorithms I-SECS-1021-03
L1 - Introduction to python Backend.pptx
Digital Strategies for Manufacturing Companies
Operating system designcfffgfgggggggvggggggggg
2025 Textile ERP Trends: SAP, Odoo & Oracle
ai tools demonstartion for schools and inter college
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
medical staffing services at VALiNTRY
Softaken Excel to vCard Converter Software.pdf
Introduction to Artificial Intelligence
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Wondershare Filmora 15 Crack With Activation Key [2025
VVF-Customer-Presentation2025-Ver1.9.pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Odoo Companies in India – Driving Business Transformation.pdf

Php a dynamic web scripting language

  • 2. P - PHP H - Hypertext P - Preprocessor
  • 3.  PHP is an acronym for “PHP Hypertext Preprocessor”. (Originally, „Personal Home Page’). It was created by Rasmus Lerdorf in 1995 to maintain his personal home page  PHP is a widely-used server scripting language, and is a powerful tool for making dynamic and interactive web pages quickly
  • 4.  PHP is an object-oriented programming language, which means that you can create objects, which can contain variables and functions  PHP scripts are executed on the server  PHP is an open source software  PHP costs nothing, it is free to download and use
  • 5. PHP files can contain text, HTML, CSS, JavaScript and PHP code PHP files are executed on the server and the result are returned to the browser as plain HTML PHP files have extension “.php”
  • 6. To start using PHP, you can: Find a web host with PHP and MySQL Support Install a web server on your own PC, and then install PHP and MySQL Visit www.php.net for free download.
  • 7. Download XAMPP installer XAMPP is an all-in-one installer package of local server, MySql and PHP * Take a look at this video on how to install XAMPP
  • 9. 1. Go to XAMPP directory folder located in local disk C: & open it 2. Click the “htdocs” folder 3. Create your own folder inside that „htdocs’ 4. Put/save all your PHP Files inside your own folder *Remember: Never rename or delete any default folder/s inside XAMPP directory except that of your own folder
  • 10. *Take the ff. steps every time you want to test/run your PHP files? 1. Open XAMPP Control Panel 2. Click the „Start‟ button of the Apache Server and of the MySQL if your PHP has a database 3. Open any web browser (Chrome, IE,Firefox, Safari etc) 4. Type in the address bar “localhost/yourfoldername” & press Enter button
  • 13. <html> <body> <?php echo "Hello World"; print “Hello World”; ?> </body> </html> Example:
  • 14. There are two basic statements to output or send text to the browser: echo or print Example: echo "Hello World"; print “Hello World”; 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.
  • 15. <html> <body> <?php //This is a single line comment # This is also a single line comment /* This is a multiple lines comment block that spans over more than one line */ ?> </body> </html>
  • 16. Variables are “containers” for storing information. It can store values like text strings, numbers or arrays. Rules for PHP variables:  A variable starts with a $ (sigil) sign, followed by the name of the variable.  A variable name must start with a letter or the underscore character  A variable name cannot start with a number  A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _)  Variable names are case sensitive ($y and $Y are two different variables)
  • 17. The correct way of declaring a variable in PHP: $var_name = value; Example: <?php $text="Hello Math!"; $x=5; $y=6; $z=$x+$y; echo $z; ?> Remember: (put quotes for text variable’s value) (no quotes needed for number variable’s value)
  • 18.  All user-defined functions, classes, and keywords (e.g. if, else, while, echo, etc.) are case- insensitive Example 1: <?php EcHo “Hello World!”; echo “Hello World!”; ECHO “Hello World!”; ?> all three echo statements are legal (and equal)
  • 19.  All variables are case-sensitive Example: <?php $color=”red”; echo “My car is “ . $color; echo “My car is “ . $COLOR; echo “My car is “ . $coLOR; ?> only the first statement will display the value of the $color variable
  • 20. ( .) – Concatenator The concatenation operator (.) is used to put two string values together. Example: <?php $txt1="Hello World!"; $txt2="What a nice day!"; echo $txt1 . " " . $txt2; ?> The output of the code above will be: Hello World! What a nice day!
  • 21. Operators are used to operate on values. Arithmetic Operators Assignment Operators Comparison Operators Logical Operators + - * / % ++ -- = += -= *= /= .= %= == != <> > < >= <= && and II or ! not
  • 22. Conditional Statements The if...else Statement Use the if....else statement to execute some code if a condition is true and another code if a condition is false.  Syntax if (condition) code to be executed if condition is true; else code to be executed if condition is false;
  • 23. The if...else Statement Example: <html> <body> <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html>
  • 24. Conditional Statements The if...elseif....else Statement Use the if....elseif...else statement to select one of several blocks of code to be executed.  Syntax if (condition) code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false;
  • 25. The if...elseif....else Statement Example: <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; elseif ($d=="Sun") echo "Have a nice Sunday!"; else echo "Have a nice day!"; ?>
  • 26. Conditional statements are used to perform different actions based on different conditions.  Syntax 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; }
  • 27. Example: <?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"; } ?>
  • 28. PHP $_POST Function The built-in „$_POST‟ function is used to collect values in a form with method="post".
  • 29. PHP $_POST Function Example: <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> When the user clicks the "Submit" button, the "welcome.php" file can now use the $_POST function to collect form data Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. Output could be something like this: Welcome John! You are 28 years old.
  • 30. Problem: How to create a program that inputs „student name‟, „attendance grade‟, „quiz grade‟, „project grade‟, & „major exam grade‟ with an output of student name, total grade and remarks using PHP?
  • 31. <html> <body> <h1> Student Grade:</h1> <form action="compute.php" method="post"> Student Name:<input type="text" name="sname" /> <br> Attendance Grade:<input type="text" name="agrade" /> <br> Quiz Grade:<input type="text" name="qgrade" /> <br> Project Grade: <input type="text" name="pgrade" /> <br> Major Exam Grade:<input type="text" name="egrade" /> <br> <input type="submit" value="Compute"/> </form> </body> Create this first file and Save this as studentgrade. php PHP file #1
  • 32. <html> <body> <?php echo $_POST["sname"]; ?> <br> <?php $attgrade = $_POST['agrade']; $quizgrade = $_POST['qgrade']; $prograde = $_POST['pgrade']; $megrade = $_POST['egrade']; $total = ($attgrade * 0.10) + ($quizgrade * 0.15) + ($prograde * 0.25) + ($megrade * 0.50); ?> <br> PHP file #2
  • 33. <?php echo 'Total Grade:' . $total; ?> <br> <?php if ($total >= 75) { echo "Remarks: Passed!"; } else { echo "Remarks: Failed!"; } ?> </body> </html> Create this second file and Save this as compute.php and run/test the two files
  • 34. Save this file as compute.php INPUT OUTPUT