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

Mirpur University of Science and Technology: Deparment Software Engineering

This document is a lecture on server-side scripting using PHP, covering its syntax, variables, and conditions. It explains the structure of web requests and responses, the characteristics of PHP as a programming language, and the tools required for development. Additionally, it discusses constants, variables, operators, and conditional statements in PHP.

Uploaded by

ahsan
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)
58 views15 pages

Mirpur University of Science and Technology: Deparment Software Engineering

This document is a lecture on server-side scripting using PHP, covering its syntax, variables, and conditions. It explains the structure of web requests and responses, the characteristics of PHP as a programming language, and the tools required for development. Additionally, it discusses constants, variables, operators, and conditional statements in PHP.

Uploaded by

ahsan
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

DEPARMENT OF SOFTWARE ENGINEERING


Server-side Scripting – PHP
(lecture # 13)

Engr. Muhammad Raees


(Lecturer)

Date: April 23, 2020


LECTURE CONTENTS

• Server side Scripting


• PHP Language
• Syntax
• Variables
• Conditions

Web Design & Development 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 Design & Development
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 Design & Development 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 Design & Development
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 Design & Development 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 Design & Development 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 Design & Development 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 Design & Development 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 Design & Development 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 Design & Development 12


Language – Conditionals

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

Web Design & Development 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 Design & Development 14


THANKS

You might also like