0% found this document useful (0 votes)
37 views15 pages

PHP Server-Side Scripting Basics

The document summarizes key points about server-side scripting using PHP: 1) PHP is an open-source server-side scripting language that is used to create dynamic web pages and interface with databases. PHP code is embedded within HTML and executed on the server-side. 2) The lecture covers PHP syntax including variables, constants, data types, operators, and conditionals. It also discusses using PHP with HTML, development tools, and compatible databases. 3) Server-side scripting allows scripts to execute on the server, for example to retrieve data from a database or calculate values, with the results then returned to the client. This provides interactive and dynamic web functionality.

Uploaded by

Bilalazam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views15 pages

PHP Server-Side Scripting Basics

The document summarizes key points about server-side scripting using PHP: 1) PHP is an open-source server-side scripting language that is used to create dynamic web pages and interface with databases. PHP code is embedded within HTML and executed on the server-side. 2) The lecture covers PHP syntax including variables, constants, data types, operators, and conditionals. It also discusses using PHP with HTML, development tools, and compatible databases. 3) Server-side scripting allows scripts to execute on the server, for example to retrieve data from a database or calculate values, with the results then returned to the client. This provides interactive and dynamic web functionality.

Uploaded by

Bilalazam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

MIRPUR UNIVERSITY OF SCIENCE AND TECHNOLOGY

DEPARTMENT OF SOFTWARE ENGINEERING


Server-side Scripting – PHP
(lecture # 13)

Engr. Muhammad Raees


(Lecturer)

Date: November 13, 2020


LECTURE CONTENTS

• Server side Scripting


• PHP Language
• Syntax
• Variables
• Conditions

Web Engineering 3
Website Structure

1. Request Content
2. Get response back
• Additionally,
• Execute a script in the client
side
• Execute a script in the server
side
• Calculate something
• Retrieve data from a
database
• Execute script in the client side

4
Web Engineering
Server-side Script

• Computer programs on the web that are executed server-side


• Usually used to provide interactive web sites that interface to databases or other
data stores
• PHP
• ASP
• Perl
• Ruby
• JSP

• For this course, PHP along with Laravel platform is used

Web Engineering 5
PHP
• PHP: Pre-processor Hypertext
• Originally called “Personal Home Page Tools”
• Used to create dynamic web pages
• Popular server-side scripting technology
• Open-source
• Anyone may view, modify and redistribute source code
• Platform independent
• Interpreted language, scripts are parsed at run-time rather than compiled
beforehand
• Compatible with many popular databases
• Structurally similar to C/C++
• Supports procedural and object-oriented paradigm

6
Web Engineering
PHP – HTML Amalgam

• PHP code can be embedded with HTML code


• HTML can also be written inside the PHP code
• PHP can also be written as a standalone program with no HTML at all
• PHP code is denoted in the page with opening and closing tags, as follows:
• <?php and ?>
• <? or ?>
• PHP statements end with a semicolon
• Comments can be added as
• // for one line comment
• /* and */ for multiple lines comment

Web Engineering 7
Development Tools

• PHP requires set of tools to run


• A web server (WAMPP, XAMPP, etc)
• PHP
• MySQL
• Additionally Laravel and others for standardized development
• Editor
• Any text editor or a specialized IDE can be used
• File have the .php extension
• The usual director for the project
• C:\wamp\htdocs\

Web Engineering 8
Language – Constants

• A constant is a placeholder for a value that you reference within your code that is
formally defined before using it
• Must begin with a letter or an underscore
• Case sensitive
• Named using all capital letters
• PHP function define() is used to assign a value to a constant

• define(“name”, “value”);

Web Engineering 9
Language – Variables

• Begin with $ sign


• First character must be a letter or underscore
• Remaining characters may be letters, numbers or underscores
• Don’t need to declare or initialize
• Case sensitive
• Data types does not require to be declare explicitly
• Supports
• Float, integer, boolean, string, array, object

• $name= “ali”; $age=20;

Web Engineering 10
Language – Type

• The gettype() function returns the type of the provided variable


• The settype() function converts a variable to the type specified by type
• A number of functions are available for determining a variable’s type
• is_array()
• is_bool()
• is_float()
• is_integer()
• is_null()
• is_numeric()
• is_string()

Web Engineering 11
Language – Operators
• Arithmetic Operators: • Logical Operators:
• +, - ,*, /, % • AND, OR, NOT
• Assignment Operators: • &&, ||, !
• = • Equality Operators:
• += ($a +=$b ), *= , /= • ==, !=, ===
• .= ($a .= $b) • Comparison Operators:
• String Operators: • >, <, <=, >=
• . , .=
• $a=“abcd”.”efgh”; $a=abcdefgh
• $a.=“ijk”; $a=abcdefghijk
• Increment/decrement Operators:
• ++,--
• $b=$a++
• $b=++$a

Web Engineering 12
Language – Conditionals

• if statement:
• if(condition) • switch statement:
• switch(variable)
•{
• {
•}
• case option:
• if-else statement: • action
• if(condition) • break;
• { } • .
• else • .
• { } • }

Web Engineering 13
References

• Chapter 5, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher,


4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8

Web Engineering 14
THANKS

You might also like