SlideShare a Scribd company logo
Introduction to Server-Side
Development with PHP
Developed by
Mr.V.Sivakumar
client and server scripts
• The fundamental difference between client and server scripts
is that in a client-side script the code is executed on the client
browser, whereas in a server-side script, it is executed on the
web server.
• In contrast, server-side source code remains hidden from the
client as it is processed on the server. The clients never get to
see the code, just the HTML output from the script.
• A server-side script can access any resources made available
to it by the server. These resources can be categorized as data
storage resources, web services, and software applications.
Module-3 15CS71-WTA-Serverside Development with PHP
Module-3 15CS71-WTA-Serverside Development with PHP
Module-3 15CS71-WTA-Serverside Development with PHP
Module-3 15CS71-WTA-Serverside Development with PHP
Quick tour of PHP
• PHP is that the programming code can be embedded directly within
an HTML file. However, instead of having an .html extension, a PHP
file will usually have the extension .php
• PHP programming code must be contained within an opening <?php
tag and a matching closing ?> tag in order to differentiate it from the
HTML. The programming code within the <?php ?> tags is
interpreted and executed, while any code outside the tags is echoed
directly out to the client.
Sample PHP Code
<?php
$user = “Siva";
?>
<!DOCTYPE html>
<html><body>
<h1>Welcome <?php echo $user; ?></h1>
<p> The server time is
<?php
echo "<strong>";
echo date("H:i:s");
echo "</strong>";
?>
</p>
</body></html>
Sample PHP Code in the browser
<!DOCTYPE html>
<html>
<body>
<h1>Welcome Siva </h1>
<p>
The server time is <strong>12:39:09</strong>
</p>
</body>
</html>
PHP comments
<?php
# single-line comment
/*
This is a multiline comment.
They are a good way to document functions or complicated blocks of
code
*/
$artist = readDatabase(); // end-of-line comment
?>
Variables
• Variables in PHP are dynamically typed, which means that you as a
programmer do not have to declare the data type of a variable.
• Variables are also loosely typed in that a variable can be assigned
different data types over time
• PHP the name of a variable is case-sensitive, so $count and $Count
are references to two different variables.
$count = 42;
PHP Data Types
Data type Description
• Boolean - A logical true or false value
• Integer - Whole numbers
• Float - Decimal numbers
• String - Letters
• Array - A collection of data of any type
• Object - Instances of classes
PHP Constant
• The define() function have two fields: constant and its value. Notice that
once it is defined, it can be referenced without using the $ symbol.
<?php
# uppercase for constants is a programming convention
define("DATABASE_LOCAL", "localhost");
define("DATABASE_NAME", "ArtStore");
define("DATABASE_USER", "Fred");
define("DATABASE_PASSWD", "F5^7%ad");
# notice that no $ prefaces constant names
$db = new mysqli(DATABASE_LOCAL, DATABASE_NAME, DATABASE_USER,
DATABASE_NAME);
?>
Writing to Output
echo ("hello");
echo "hello";
$username = “Siva";
echo "Hello". $username; // Hello Siva
Include Files
• The difference between include and require lies in what happens when
the specified file cannot be included (generally because it doesn’t exist
or the server doesn’t have permission to access it). With include, a
warning is displayed and then execution continues. With require, an
error is displayed and execution stops.
<?php
include "somefile.php";
require "somefile.php";
?>
Functions
• PHP allows you to define functions. Just like with JavaScript, a function in
PHP contains a small bit of code that accomplishes the task
• PHP there are two types of function: user-defined functions and built-in
functions. A user-defined function is one that you the programmer define. A
built-in function is one of the functions that come with the PHP environment
<?php
function getCurrentTime() {
return date("H:i:s");
}
$output = getCurrentTime();
echo getCurrentTime();
?>
Functions Passing a parameter by value
<?php
function changeParameter($arg) {
$arg += 300;
echo “arg=" . $arg;
}
$initial = 15;
echo "initial=" . $initial; // output: initial=15
changeParameter($initial); // output: arg=315
echo “ initial= " . $initial; // output: initial=15
?>
Functions Passing a parameter by reference
function changeParameter(&$arg) {
$arg += 300;
echo "<br/>arg=". $arg;
}
$initial = 15;
echo "<br/>initial=" . $initial; // output: initial=15
changeParameter($initial); // output: arg=315
echo "<br/>initial=" . $initial; // output: initial=315
Module-3 15CS71-WTA-Serverside Development with PHP
variable scope within Functions
Thank you
Source Reference: Randy Connolly, Ricardo Hoar, Fundamentals of Web Development, Pearson

More Related Content

PPT
Scripting languages
PDF
Client side scripting
PPTX
Web programming
PPT
Fm 2
PPTX
Js syntax
PDF
Apache Thrift : One Stop Solution for Cross Language Communication
PPTX
Search Engine Project Presentation
Scripting languages
Client side scripting
Web programming
Fm 2
Js syntax
Apache Thrift : One Stop Solution for Cross Language Communication
Search Engine Project Presentation

What's hot (19)

PPTX
Programming Paradigm & Languages
PPTX
Facebook thrift
PPTX
Cloudy Open Source and DevOps
PPTX
Introduction to php
PPTX
Asp.net c# mvc Training: Day-3 of Day-9
PPTX
PHP ITCS 323
PPTX
Rest API Testing
PPTX
Www(alyssa) (2)
PPTX
Www and http
PDF
3. Java Script
PDF
Ch 5: Bypassing Client-Side Controls
PDF
Automating and Testing a REST API
PPTX
Java script Session No 1
PPTX
Java 8 concurrency abstractions
DOC
Java script by Act Academy
PDF
REST-API overview / concepts
PPTX
Java script
PPTX
Phalcon 2 High Performance APIs - DevWeekPOA 2015
PDF
JavaScript - Chapter 15 - Debugging Techniques
Programming Paradigm & Languages
Facebook thrift
Cloudy Open Source and DevOps
Introduction to php
Asp.net c# mvc Training: Day-3 of Day-9
PHP ITCS 323
Rest API Testing
Www(alyssa) (2)
Www and http
3. Java Script
Ch 5: Bypassing Client-Side Controls
Automating and Testing a REST API
Java script Session No 1
Java 8 concurrency abstractions
Java script by Act Academy
REST-API overview / concepts
Java script
Phalcon 2 High Performance APIs - DevWeekPOA 2015
JavaScript - Chapter 15 - Debugging Techniques
Ad

Similar to Module-3 15CS71-WTA-Serverside Development with PHP (20)

PPT
PHP - Introduction to PHP Fundamentals
PPT
introduction to php notes for engineering students.ppt
PPTX
Php reports sumit
PPT
php 1
PPTX
Introduction to PHP from Beginning to End
PPT
PPTX
Web Application Development using PHP Chapter 1
PDF
JS BASICS JAVA SCRIPT SCRIPTING
PPTX
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
PPTX
Php intro
PDF
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
PPTX
introduction to php and its uses in daily
PPT
PPTX
PHP.pptx is the Best Explanation of ppts
PPTX
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PPTX
PHP - Introduction to PHP Fundamentals
introduction to php notes for engineering students.ppt
Php reports sumit
php 1
Introduction to PHP from Beginning to End
Web Application Development using PHP Chapter 1
JS BASICS JAVA SCRIPT SCRIPTING
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php intro
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
introduction to php and its uses in daily
PHP.pptx is the Best Explanation of ppts
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
Ad

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
web development for engineering and engineering
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Construction Project Organization Group 2.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Embodied AI: Ushering in the Next Era of Intelligent Systems
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Automation-in-Manufacturing-Chapter-Introduction.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
web development for engineering and engineering
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Foundation to blockchain - A guide to Blockchain Tech
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
Construction Project Organization Group 2.pptx
UNIT 4 Total Quality Management .pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
R24 SURVEYING LAB MANUAL for civil enggi
bas. eng. economics group 4 presentation 1.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx

Module-3 15CS71-WTA-Serverside Development with PHP

  • 1. Introduction to Server-Side Development with PHP Developed by Mr.V.Sivakumar
  • 2. client and server scripts • The fundamental difference between client and server scripts is that in a client-side script the code is executed on the client browser, whereas in a server-side script, it is executed on the web server. • In contrast, server-side source code remains hidden from the client as it is processed on the server. The clients never get to see the code, just the HTML output from the script. • A server-side script can access any resources made available to it by the server. These resources can be categorized as data storage resources, web services, and software applications.
  • 7. Quick tour of PHP • PHP is that the programming code can be embedded directly within an HTML file. However, instead of having an .html extension, a PHP file will usually have the extension .php • PHP programming code must be contained within an opening <?php tag and a matching closing ?> tag in order to differentiate it from the HTML. The programming code within the <?php ?> tags is interpreted and executed, while any code outside the tags is echoed directly out to the client.
  • 8. Sample PHP Code <?php $user = “Siva"; ?> <!DOCTYPE html> <html><body> <h1>Welcome <?php echo $user; ?></h1> <p> The server time is <?php echo "<strong>"; echo date("H:i:s"); echo "</strong>"; ?> </p> </body></html>
  • 9. Sample PHP Code in the browser <!DOCTYPE html> <html> <body> <h1>Welcome Siva </h1> <p> The server time is <strong>12:39:09</strong> </p> </body> </html>
  • 10. PHP comments <?php # single-line comment /* This is a multiline comment. They are a good way to document functions or complicated blocks of code */ $artist = readDatabase(); // end-of-line comment ?>
  • 11. Variables • Variables in PHP are dynamically typed, which means that you as a programmer do not have to declare the data type of a variable. • Variables are also loosely typed in that a variable can be assigned different data types over time • PHP the name of a variable is case-sensitive, so $count and $Count are references to two different variables. $count = 42;
  • 12. PHP Data Types Data type Description • Boolean - A logical true or false value • Integer - Whole numbers • Float - Decimal numbers • String - Letters • Array - A collection of data of any type • Object - Instances of classes
  • 13. PHP Constant • The define() function have two fields: constant and its value. Notice that once it is defined, it can be referenced without using the $ symbol. <?php # uppercase for constants is a programming convention define("DATABASE_LOCAL", "localhost"); define("DATABASE_NAME", "ArtStore"); define("DATABASE_USER", "Fred"); define("DATABASE_PASSWD", "F5^7%ad"); # notice that no $ prefaces constant names $db = new mysqli(DATABASE_LOCAL, DATABASE_NAME, DATABASE_USER, DATABASE_NAME); ?>
  • 14. Writing to Output echo ("hello"); echo "hello"; $username = “Siva"; echo "Hello". $username; // Hello Siva
  • 15. Include Files • The difference between include and require lies in what happens when the specified file cannot be included (generally because it doesn’t exist or the server doesn’t have permission to access it). With include, a warning is displayed and then execution continues. With require, an error is displayed and execution stops. <?php include "somefile.php"; require "somefile.php"; ?>
  • 16. Functions • PHP allows you to define functions. Just like with JavaScript, a function in PHP contains a small bit of code that accomplishes the task • PHP there are two types of function: user-defined functions and built-in functions. A user-defined function is one that you the programmer define. A built-in function is one of the functions that come with the PHP environment <?php function getCurrentTime() { return date("H:i:s"); } $output = getCurrentTime(); echo getCurrentTime(); ?>
  • 17. Functions Passing a parameter by value <?php function changeParameter($arg) { $arg += 300; echo “arg=" . $arg; } $initial = 15; echo "initial=" . $initial; // output: initial=15 changeParameter($initial); // output: arg=315 echo “ initial= " . $initial; // output: initial=15 ?>
  • 18. Functions Passing a parameter by reference function changeParameter(&$arg) { $arg += 300; echo "<br/>arg=". $arg; } $initial = 15; echo "<br/>initial=" . $initial; // output: initial=15 changeParameter($initial); // output: arg=315 echo "<br/>initial=" . $initial; // output: initial=315
  • 21. Thank you Source Reference: Randy Connolly, Ricardo Hoar, Fundamentals of Web Development, Pearson