SlideShare a Scribd company logo
PHP:
Hypertext
Preprocessor
Content
 What is Server?
 Types of servers.
 Basic PHP.
 Syntax of PHP.
 Variables.
 Operators.
 Conditional Statements.
 Loops.
 PHP Function.
 PHP Array & It‟s types.
4 Basic PHP
What is Server ?
 In a technical sense, a server is an instance of a computer
program that accepts and responds to requests made by
another program, known as a client.
 Less formally, any device that runs server software could be
considered a server as well.
 Servers are used to manage network resources.
 For example, a user may setup a server to control access to
a network, send/receive e-mail, manage print jobs, or host
a website.
What is Server ? (cont.)
 Some servers are committed to a specific task, often referred to as
dedicated.
 As a result, there are a number of dedicated server categories, like print
servers, file servers, network servers, and database servers.
 However, many servers today are shared servers which can take on the
responsibility of e-mail, DNS, FTP, and even multiple websites in the case of
a web server.
 Because they are commonly used to deliver services that are required
constantly, most servers are never turned off.
 Consequently, when servers fail, they can cause the network users and
company many problems.
 To alleviate these issues, servers are commonly high-end computers setup
to be fault tolerant.
Examples(types) of servers
 The following list contains various server types.
1. Application server
2. Blade server
3. Cloud server
4. Database server
5. Dedicated server
6. File server
7. Mail server
8. Print server
9. Proxy server
10. Standalone server
11. Web server
Application server
 The application server is a framework, an environment where applications
can run, no matter what they are or what functions they perform.
 An application server can be used to develop and run web-based
applications.
 There are a number of different types of application servers, including
Java, PHP and .NET Framework application servers.
Blade
 A blade may refer to any of the following:
1. When referring to a network router, switch, server, or other network
device, a blade(also known as an expansion module) is a
hardware component that can be installed into a chassis.
2. When talking about servers, a blade, blade server, or a high density
server is one rack mount unit that is capable of holding dozens of
different servers.
Cloud computing
 Cloud computing is a term used to describe services provided
over a network by a collection of remote servers.
 This abstract “cloud” of computers provides massive, distributed
storage and processing power, which can be accessed by any
Internet-connected device running a web browser.
 Examples of cloud services
 Amazon Web Services (AWS)
 Dashlane
 Google App Engine
 Google Calendar
 Microsoft OneDrive
 Etc..
Database Server
 A database server is a computer system that provides other
computers with services related to accessing and retrieving
data from a database.
 Access to the database server may occur via a “front end”
running locally a user‟s machine (e.g., phpMyAdmin), or
“back end” running on the database server itself, accessed
by remote shell.
 After the information within the database is retrieved it is
outputted to the user requesting the data.
Dedicated server
 A server that is hosted by a company and only allows one company to lease
and access it is called a dedicated server.
 It is “dedicated” to the one client and is not shared with any other clients.
 Dedicated servers usually allow the client to choose what operating system is
installed on it and what type of hardware.
 In most cases, the hosting company performs all or most of the maintenance on
the dedicated server. This includes:
 operating system updates
 updates to any installed applications
 monitoring of the server and applications
 firewall maintenance
 intrusion detection and prevention
 data backups
 disaster recovery
File server
 A file server is a computer on a network that is used to
provide users on a network with access to files.
Mail server
 A remote or central computer that holds electronic mail (e-mail)
messages for clients on a network is called a mail server.
 A mail server is similar to the post office, where mail is stored and
sorted before being sent to its final destination.
 When the user requests his or her e-mail, contact is established with
the mail server, which then delivers all stored to the client‟s computer.
Print server
 Computer or standalone device responsible for managing
one or more printers on a network.
 Because of the load required for a print job, a print
server does not need to be a fast computer.
 The picture is an example of a wireless standalone print
server from Cisco.
Proxy server
 A proxy is a computer server or software program that is part of
the gateway server or another computer that separates a local
network from outside networks.
 A proxy server will cache all pages accessed through the network
allowing users who may want to visit that same page to load it faster
and reduce the networks bandwidth.
 When a page is accessed that is not in the proxy server‟s cache, the
proxy server accesses the page using its own IP address, caches the
page, and forward it to the user.
SAS
 SAS may refer to any of the following:
 Short for Serial Attached SCSI, SASis a serial transmission replacement
for the parallel SCSI. SAS is an improvement of regular SCSI in that it
allow up to 128 devices to be connected at the same time with
transmission speeds of 3.0 Gb/s. SAS devices have two data ports and
can communicate with both SCSI and SATA.
 Short for Standalone Server, SASis a server that does not rely on any
other servers or services.
 Abbreviation sometimes used to describe SUPER Anti Spyware.
Web server
 Computer or collection of computers used to deliver web pages
and other content to multiple users.
 Below are some examples of web server software.
 Apache HTTP Server
 Apache Tomcat
 Microsoft IIS
 LAMP
 FastCGI
 LIGHTTPD
 XAMP
What is PHP(7.3)??
 PHP is an acronym for "PHP: Hypertext Preprocessor"
 PHP is a widely-used, open source scripting language
 PHP scripts are executed on the server
 PHP is free to download and use
 It is powerful enough to be at the core of the biggest blogging system on the
web (WordPress)!
 It is deep enough to run the largest social network (Facebook)!
Components of PHP
 To develop and run PHP Web pages three vital components need to be installed.
 Web Server
 Database
 PHP Parser
HTML v/s PHP
 How it differs from HTML
 differentiates PHP with client-side language like HTML is, PHP codes are executed on
server whereas HTML codes are directly rendered on the browser. PHP codes are first
executed on the server and then the result is returned to the browser.
Characteristics of PHP
 Simplicity
 Efficiency
 Security
 Flexibility
 Familiarity
 Inter-operable(php in html, html in php)
 PHP is whitespace insensitive
 PHP is case sensitive
Application of PHP
 PHP can generate dynamic page content
 PHP can create, open, read, write, delete, and close files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can be used to control user-access
 PHP can encrypt data
Basic PHP
 Basic PHP Syntax

 // This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
Variables in PHP
 Creating (Declaring) PHP Variables
 <?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
 Rules for PHP variables:
 A variable starts with the $ 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 ($age and $AGE are two different variables)
Constant in PHP
 There is no need to write a dollar sign ($) before a constant, where as in Variable
one has to write a dollar sign.
 Constants cannot be defined by simple assignment, they may only be defined
using the define() function.
 Constants may be defined and accessed anywhere without regard to variable
scoping rules.
 Once the Constants have been set, may not be redefined or undefined.
 <?php
define("MINSIZE", 50);
echo MINSIZE;
?>
Example of Variable
 <?php
$txt = “How are you?";
echo “Hello, " . $txt . "!";
?>
 Output: Hello, How are you?
 <?php
$txt = “How are you?";
echo “Hello, $txt !";
?>
 Output: ?
PHP Variables Scope
 PHP has three different variable scopes:
 local
 global
 static
 PHP The global Keyword
 global $x, $y;
 $GLOBALS[index] Array
 $GLOBALS['y'],
 $GLOBALS[„x']
 PHP The static Keyword
 static $x;
PHP echo & Print
 The PHP echo Statement
 echo or echo()
 The PHP print Statement
 print or print()
 echo has no return value while print has a return value of 1 so it can be used in
expressions.
 echo can take multiple parameters (although such usage is rare) while print can
take one argument.
 echo is marginally faster than print.
PHP Data Types
 PHP supports the following data types:
 String
 Integer
 Float (floating point numbers - also called double)
 Boolean
 Array
 Object
 NULL
 Resource
PHP Class & Object
 <?php
class Car {
function Car() {
$this->model = “Ferrari";
}
}
// create an object
$herbie = new Car();
// show object properties
echo $herbie->model;
?>
PHP 5 Strings
 Length of a String
 strlen("Hello world!"); // outputs 12
 Number of Words in a String
 str_word_count("Hello world!"); // outputs 2
 Reverse a String
 strrev("Hello world!"); // outputs !dlrow olleH
 Search For a Specific Text Within a String
 strpos("Hello world!", "world"); // outputs 6
 Replace Text Within a String
 str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
PHP Constants
 define(name, value, case-insensitive)
 name: Specifies the name of the constant
 value: Specifies the value of the constant
 case-insensitive: Specifies whether the constant name should be case-insensitive.
Default is false
 <?php
define("GREETING", "Welcome to CHARUSAT!");
echo GREETING;
?>
PHP Operators
 PHP divides the operators in the following groups:
 Arithmetic operators
 Assignment operators
 Comparison operators
 Increment/Decrement operators
 Logical operators
 String operators
 Array operators
PHP Arithmetic Operators
Operator Name Example Result
+ Addition $x + $y Sum of $x and $y
- Subtraction $x - $y Difference of $x and $y
* Multiplication $x * $y Product of $x and $y
/ Division $x / $y Quotient of $x and $y
% Modulus $x % $y Remainder of $x divided by $y
** Exponentiation $x ** $y Result of raising $x to the $y'th power
(Introduced in PHP 5.6)
PHP Assignment Operators
Assignment Same as... Description
x = y x = y The left operand gets set to the value of the
expression on the right
x += y x = x + y Addition
x -= y x = x - y Subtraction
x *= y x = x * y Multiplication
x /= y x = x / y Division
x %= y x = x % y Modulus
PHP Comparison Operators
Operator Name Example Result
== Equal $x == $y Returns true if $x is equal to $y
=== Identical $x === $y Returns true if $x is equal to $y,
and they are of the same type
!= Not equal $x != $y Returns true if $x is not equal to $y
<> Not equal $x <> $y Returns true if $x is not equal to $y
!== Not identical $x !== $y Returns true if $x is not equal to $y,
or they are not of the same type
> Greater than $x > $y Returns true if $x is greater than $y
< Less than $x < $y Returns true if $x is less than $y
>= Greater than
or equal to
$x >= $y Returns true if $x is greater than
or equal to $y
<= Less than
or equal to
$x <= $y Returns true if $x is less than
or equal to $y
PHP Increment / Decrement
Operators
Operator Name Description
++$x Pre-increment Increments $x by one, then returns $x
$x++ Post-increment Returns $x, then increments $x by one
--$x Pre-decrement Decrements $x by one, then returns $x
$x-- Post-decrement Returns $x, then decrements $x by one
PHP Logical Operators
Operator Name Example Result
and And $x and $y True if both $x and $y are true
or Or $x or $y True if either $x or $y is true
xor Xor $x xor $y True if either $x or $y is true, but not both
&& And $x && $y True if both $x and $y are true
|| Or $x || $y True if either $x or $y is true
! Not !$x True if $x is not true
PHP String Operators
Operator Name Example Result
. Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2
.= Concatenation
assignment
$txt1 .= $txt2 Appends $txt2 to $txt1
PHP Array Operators
Operator Name Example Result
+ Union $x + $y Union of $x and $y
== Equality $x == $y Returns true if $x and $y have the
same key/value pairs
=== Identity $x === $y Returns true if $x and $y have the
same key/value pairs in the same
order and of the same types
!= Inequality $x != $y Returns true if $x is not equal to $y
<> Inequality $x <> $y Returns true if $x is not equal to $y
!== Non-identity $x !== $y Returns true if $x is not identical to $y
PHP Conditional Statements
 In PHP we have the following conditional statements:
 if statement - executes some code only if a specified condition is true
 if...else statement - executes some code if a condition is true and another code if the
condition is false
 if...elseif....else statement - specifies a new condition to test, if the first condition is false
 switch statement - selects one of many blocks of code to be executed
If...elseif…else Statement
 <?php
$t = 12;
if ($t < "10") {
echo "Have a good morning!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Switch Statement
 <?php
$favcolor = "red";
switch ($favcolor) {
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, or green!";
}
?>
PHP Loops
 In PHP, we have the following looping statements:
 while - loops through a block of code as long as the specified condition is true
 do...while - loops through a block of code once, and then repeats the loop as long as
the specified condition is true
 for - loops through a block of code a specified number of times
 foreach - loops through a block of code for each element in an array
The PHP while Loop
 <?php
$x = 1;
while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
?>
The PHP do...while Loop
 <?php
$x = 1;
do {
echo "The number is: $x <br>";
$x++;
} while ($x <= 5);
?>
The PHP for Loops
 The PHP for Loop
 <?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}
?>
 The PHP foreach Loop
 <?php
$colors = array("red", "green", "blue", "yellow");
foreach ($colors as $value) {
echo "$value <br>";
}
?>
PHP Functions
 PHP User Defined Functions
 A function is a block of statements that can be used repeatedly in a program.
 A function will not execute immediately when a page loads.
 A function will be executed by a call to the function.
 <?php
function writeMsg() {
echo "Hello world!";
}
writeMsg(); // call the function
?>
PHP Function Arguments
 <?php
function familyName($fname, $year) {
echo "$fname Stilinski Born in $year <br>";
}
familyName("Hege", "1975");
familyName("Stale", "1978");
familyName("Kai Jim", "1983");
?>
PHP Default Argument Value
 <?php
function setHeight($minheight = 50) {
echo "The height is : $minheight <br>";
}
setHeight(350);
setHeight(); // will use the default value of 50
setHeight(135);
setHeight(80);
?>
PHP Functions - Returning
values
 <?php
function sum($x, $y) {
$z = $x + $y;
return $z;
}
echo "5 + 10 = " . sum(5, 10) . "<br>";
echo "7 + 13 = " . sum(7, 13) . "<br>";
echo "2 + 4 = " . sum(2, 4);
?>
PHP Arrays
 In PHP, there are three types of arrays:
 Indexed arrays - Arrays with a numeric index
 Associative arrays - Arrays with named keys
 Multidimensional arrays - Arrays containing one or more arrays
PHP Indexed Arrays
 <?php
$cars = array("Volvo", "BMW", "Toyota");
OR
$cars[0] = “Volvo”;
$cars[1] = “BMW”;
$cars[2] = “Toyota”;
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
 The Length of an Array - The count() Function
 count($cars);
PHP Indexed Arrays
 <?php
$cars = array("Volvo", "BMW", "Toyota");
OR
$cars[0] = “Volvo”;
$cars[1] = “BMW”;
$cars[2] = “Toyota”;
$arrlength = count($cars);
for($x = 0; $x < $arrlength; $x++) {
echo $cars[$x];
echo "<br>";
}
?>
PHP Associative Arrays
 <?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "Peter is " . $age['Peter'] . " years old.";
?>
 <?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
foreach($age as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
?>
PHP Multidimensional Arrays
 <?php
$contacts = array(
array( "name" => "Peter Parker", "email" => "peterparker@mail.com", ),
array( "name" => "Clark Kent", "email" => "clarkkent@mail.com", ),
array( "name" => "Harry Potter", "email" => "harrypotter@mail.com", ) );
echo "Peter Parker's Email-id is: " . $contacts[0]["email"];
print_r($contact);
var_dump($cities);
PHP Multidimensional Arrays
 $favorites = array(
"Dave Punk" => array(
"mob" => "5689741523",
"email" => "davepunk@gmail.com",
),
"Dave Punk" => array(
"mob" => "2584369721",
"email" => "montysmith@gmail.com",
),
"John Flinch" => array(
"mob" => "9875147536",
"email" => "johnflinch@gmail.com",
)
);
keys = array_keys($favorites);
for($i = 0; $i < count($favorites); $i++)
{
echo $keys[$i] . "n";
foreach($favorites[$keys[$i]] as $key => $value) {
echo $key . " : " . $value . "n";
}
echo "n";
}
PHP Include & Require
 The include (or require) statement takes all the text/code/markup that exists in
the specified file and copies it into the file that uses the include statement.
 It is possible to insert the content of one PHP file into another PHP file
 The include and require statements are identical, except upon failure:
 require will produce a fatal error (E_COMPILE_ERROR) and stop the script
 include will only produce a warning (E_WARNING) and the script will continue
PHP Include & Require
 Footer.php
 <?php
echo "<p>Copyright &copy; 2017-" . date("Y") . " charusat.ac.in</p>";
?>
 Index.php/home.php/dept.php
 <html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include 'footer.php';?>
</body>
</html>
PHP Handling Form input
 GET v/s POST Method
 $_GET, $_POST, $_REQUEST

More Related Content

PDF
Security in php
PPTX
Apache web server
PDF
Apache Server Tutorial
PPT
Apache Web Server Setup 3
PPT
Apache Web Server Architecture Chaitanya Kulkarni
PDF
Configuring the Apache Web Server
PPT
Apache Web Server Setup 1
PPT
Apache Ppt
Security in php
Apache web server
Apache Server Tutorial
Apache Web Server Setup 3
Apache Web Server Architecture Chaitanya Kulkarni
Configuring the Apache Web Server
Apache Web Server Setup 1
Apache Ppt

What's hot (20)

PPT
Web servers
ODP
PHP Training: Module 1
PPT
Apache Web Server Setup 4
PPTX
Web Server - Internet Applications
PPT
Apache ppt
PDF
Apache web server tutorial for linux
PPTX
Apache server configuration & optimization
PPT
Apache
ODP
web server
PPT
Securing Your Web Server
ODP
Linux Apache Php Mysql Lamp1273
PPT
ODP
Web Server-Side Programming Techniques
PDF
Apache Web server Complete Guide
PPTX
ASP.NET WEB API Training
PPTX
Apache web server
PPT
Web Servers: Architecture and Security
PPT
Apache
PDF
Apache Tutorial
PDF
Web server
Web servers
PHP Training: Module 1
Apache Web Server Setup 4
Web Server - Internet Applications
Apache ppt
Apache web server tutorial for linux
Apache server configuration & optimization
Apache
web server
Securing Your Web Server
Linux Apache Php Mysql Lamp1273
Web Server-Side Programming Techniques
Apache Web server Complete Guide
ASP.NET WEB API Training
Apache web server
Web Servers: Architecture and Security
Apache
Apache Tutorial
Web server
Ad

Similar to 4 Basic PHP (20)

PPT
Php unit i
PPTX
PHP Hypertext Preprocessor
PPTX
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
PPTX
Introduction to webprogramming using PHP and MySQL
PPTX
Web Application Development using PHP Chapter 1
ODP
PHP BASIC PRESENTATION
PDF
PHP Basics
PPTX
Introduction to PHP.pptx
PPTX
PHP language presentation
PDF
Introduction to php
PPT
PHP and MySQL
PPT
PDF
PHP in Web development and Applications.pdf
PPTX
introduction to php and its uses in daily
PPTX
Php unit i
PPT
PPT
345345
PPT
ssfsd fsdf ds f
PPT
PPT
IntroductiontoPHP.ppt
Php unit i
PHP Hypertext Preprocessor
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Introduction to webprogramming using PHP and MySQL
Web Application Development using PHP Chapter 1
PHP BASIC PRESENTATION
PHP Basics
Introduction to PHP.pptx
PHP language presentation
Introduction to php
PHP and MySQL
PHP in Web development and Applications.pdf
introduction to php and its uses in daily
Php unit i
345345
ssfsd fsdf ds f
IntroductiontoPHP.ppt
Ad

More from Jalpesh Vasa (15)

PDF
Object Oriented PHP - PART-1
PDF
Object Oriented PHP - PART-2
PDF
5. HTML5
PDF
4.4 PHP Session
PDF
4.3 MySQL + PHP
PDF
4.2 PHP Function
PDF
4.1 PHP Arrays
PDF
3.2.1 javascript regex example
PDF
3.2 javascript regex
PDF
3. Java Script
PDF
3.1 javascript objects_DOM
PDF
2 introduction css
PDF
1 web technologies
PDF
Remote Method Invocation in JAVA
PDF
Kotlin for android development
Object Oriented PHP - PART-1
Object Oriented PHP - PART-2
5. HTML5
4.4 PHP Session
4.3 MySQL + PHP
4.2 PHP Function
4.1 PHP Arrays
3.2.1 javascript regex example
3.2 javascript regex
3. Java Script
3.1 javascript objects_DOM
2 introduction css
1 web technologies
Remote Method Invocation in JAVA
Kotlin for android development

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
GDM (1) (1).pptx small presentation for students
Supply Chain Operations Speaking Notes -ICLT Program
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
Module 4: Burden of Disease Tutorial Slides S2 2025
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Sports Quiz easy sports quiz sports quiz
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Structure & Organelles in detailed.
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
Renaissance Architecture: A Journey from Faith to Humanism

4 Basic PHP

  • 2. Content  What is Server?  Types of servers.  Basic PHP.  Syntax of PHP.  Variables.  Operators.  Conditional Statements.  Loops.  PHP Function.  PHP Array & It‟s types.
  • 4. What is Server ?  In a technical sense, a server is an instance of a computer program that accepts and responds to requests made by another program, known as a client.  Less formally, any device that runs server software could be considered a server as well.  Servers are used to manage network resources.  For example, a user may setup a server to control access to a network, send/receive e-mail, manage print jobs, or host a website.
  • 5. What is Server ? (cont.)  Some servers are committed to a specific task, often referred to as dedicated.  As a result, there are a number of dedicated server categories, like print servers, file servers, network servers, and database servers.  However, many servers today are shared servers which can take on the responsibility of e-mail, DNS, FTP, and even multiple websites in the case of a web server.  Because they are commonly used to deliver services that are required constantly, most servers are never turned off.  Consequently, when servers fail, they can cause the network users and company many problems.  To alleviate these issues, servers are commonly high-end computers setup to be fault tolerant.
  • 6. Examples(types) of servers  The following list contains various server types. 1. Application server 2. Blade server 3. Cloud server 4. Database server 5. Dedicated server 6. File server 7. Mail server 8. Print server 9. Proxy server 10. Standalone server 11. Web server
  • 7. Application server  The application server is a framework, an environment where applications can run, no matter what they are or what functions they perform.  An application server can be used to develop and run web-based applications.  There are a number of different types of application servers, including Java, PHP and .NET Framework application servers.
  • 8. Blade  A blade may refer to any of the following: 1. When referring to a network router, switch, server, or other network device, a blade(also known as an expansion module) is a hardware component that can be installed into a chassis. 2. When talking about servers, a blade, blade server, or a high density server is one rack mount unit that is capable of holding dozens of different servers.
  • 9. Cloud computing  Cloud computing is a term used to describe services provided over a network by a collection of remote servers.  This abstract “cloud” of computers provides massive, distributed storage and processing power, which can be accessed by any Internet-connected device running a web browser.  Examples of cloud services  Amazon Web Services (AWS)  Dashlane  Google App Engine  Google Calendar  Microsoft OneDrive  Etc..
  • 10. Database Server  A database server is a computer system that provides other computers with services related to accessing and retrieving data from a database.  Access to the database server may occur via a “front end” running locally a user‟s machine (e.g., phpMyAdmin), or “back end” running on the database server itself, accessed by remote shell.  After the information within the database is retrieved it is outputted to the user requesting the data.
  • 11. Dedicated server  A server that is hosted by a company and only allows one company to lease and access it is called a dedicated server.  It is “dedicated” to the one client and is not shared with any other clients.  Dedicated servers usually allow the client to choose what operating system is installed on it and what type of hardware.  In most cases, the hosting company performs all or most of the maintenance on the dedicated server. This includes:  operating system updates  updates to any installed applications  monitoring of the server and applications  firewall maintenance  intrusion detection and prevention  data backups  disaster recovery
  • 12. File server  A file server is a computer on a network that is used to provide users on a network with access to files.
  • 13. Mail server  A remote or central computer that holds electronic mail (e-mail) messages for clients on a network is called a mail server.  A mail server is similar to the post office, where mail is stored and sorted before being sent to its final destination.  When the user requests his or her e-mail, contact is established with the mail server, which then delivers all stored to the client‟s computer.
  • 14. Print server  Computer or standalone device responsible for managing one or more printers on a network.  Because of the load required for a print job, a print server does not need to be a fast computer.  The picture is an example of a wireless standalone print server from Cisco.
  • 15. Proxy server  A proxy is a computer server or software program that is part of the gateway server or another computer that separates a local network from outside networks.  A proxy server will cache all pages accessed through the network allowing users who may want to visit that same page to load it faster and reduce the networks bandwidth.  When a page is accessed that is not in the proxy server‟s cache, the proxy server accesses the page using its own IP address, caches the page, and forward it to the user.
  • 16. SAS  SAS may refer to any of the following:  Short for Serial Attached SCSI, SASis a serial transmission replacement for the parallel SCSI. SAS is an improvement of regular SCSI in that it allow up to 128 devices to be connected at the same time with transmission speeds of 3.0 Gb/s. SAS devices have two data ports and can communicate with both SCSI and SATA.  Short for Standalone Server, SASis a server that does not rely on any other servers or services.  Abbreviation sometimes used to describe SUPER Anti Spyware.
  • 17. Web server  Computer or collection of computers used to deliver web pages and other content to multiple users.  Below are some examples of web server software.  Apache HTTP Server  Apache Tomcat  Microsoft IIS  LAMP  FastCGI  LIGHTTPD  XAMP
  • 18. What is PHP(7.3)??  PHP is an acronym for "PHP: Hypertext Preprocessor"  PHP is a widely-used, open source scripting language  PHP scripts are executed on the server  PHP is free to download and use  It is powerful enough to be at the core of the biggest blogging system on the web (WordPress)!  It is deep enough to run the largest social network (Facebook)!
  • 19. Components of PHP  To develop and run PHP Web pages three vital components need to be installed.  Web Server  Database  PHP Parser HTML v/s PHP  How it differs from HTML  differentiates PHP with client-side language like HTML is, PHP codes are executed on server whereas HTML codes are directly rendered on the browser. PHP codes are first executed on the server and then the result is returned to the browser.
  • 20. Characteristics of PHP  Simplicity  Efficiency  Security  Flexibility  Familiarity  Inter-operable(php in html, html in php)  PHP is whitespace insensitive  PHP is case sensitive
  • 21. Application of PHP  PHP can generate dynamic page content  PHP can create, open, read, write, delete, and close files on the server  PHP can collect form data  PHP can send and receive cookies  PHP can add, delete, modify data in your database  PHP can be used to control user-access  PHP can encrypt data
  • 22. Basic PHP  Basic PHP Syntax   // This is a single-line comment # This is also a single-line comment /* This is a multiple-lines comment block that spans over multiple lines */
  • 23. Variables in PHP  Creating (Declaring) PHP Variables  <?php $txt = "Hello world!"; $x = 5; $y = 10.5; ?>  Rules for PHP variables:  A variable starts with the $ 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 ($age and $AGE are two different variables)
  • 24. Constant in PHP  There is no need to write a dollar sign ($) before a constant, where as in Variable one has to write a dollar sign.  Constants cannot be defined by simple assignment, they may only be defined using the define() function.  Constants may be defined and accessed anywhere without regard to variable scoping rules.  Once the Constants have been set, may not be redefined or undefined.  <?php define("MINSIZE", 50); echo MINSIZE; ?>
  • 25. Example of Variable  <?php $txt = “How are you?"; echo “Hello, " . $txt . "!"; ?>  Output: Hello, How are you?  <?php $txt = “How are you?"; echo “Hello, $txt !"; ?>  Output: ?
  • 26. PHP Variables Scope  PHP has three different variable scopes:  local  global  static  PHP The global Keyword  global $x, $y;  $GLOBALS[index] Array  $GLOBALS['y'],  $GLOBALS[„x']  PHP The static Keyword  static $x;
  • 27. PHP echo & Print  The PHP echo Statement  echo or echo()  The PHP print Statement  print or print()  echo has no return value while print has a return value of 1 so it can be used in expressions.  echo can take multiple parameters (although such usage is rare) while print can take one argument.  echo is marginally faster than print.
  • 28. PHP Data Types  PHP supports the following data types:  String  Integer  Float (floating point numbers - also called double)  Boolean  Array  Object  NULL  Resource
  • 29. PHP Class & Object  <?php class Car { function Car() { $this->model = “Ferrari"; } } // create an object $herbie = new Car(); // show object properties echo $herbie->model; ?>
  • 30. PHP 5 Strings  Length of a String  strlen("Hello world!"); // outputs 12  Number of Words in a String  str_word_count("Hello world!"); // outputs 2  Reverse a String  strrev("Hello world!"); // outputs !dlrow olleH  Search For a Specific Text Within a String  strpos("Hello world!", "world"); // outputs 6  Replace Text Within a String  str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
  • 31. PHP Constants  define(name, value, case-insensitive)  name: Specifies the name of the constant  value: Specifies the value of the constant  case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false  <?php define("GREETING", "Welcome to CHARUSAT!"); echo GREETING; ?>
  • 32. PHP Operators  PHP divides the operators in the following groups:  Arithmetic operators  Assignment operators  Comparison operators  Increment/Decrement operators  Logical operators  String operators  Array operators
  • 33. PHP Arithmetic Operators Operator Name Example Result + Addition $x + $y Sum of $x and $y - Subtraction $x - $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y / Division $x / $y Quotient of $x and $y % Modulus $x % $y Remainder of $x divided by $y ** Exponentiation $x ** $y Result of raising $x to the $y'th power (Introduced in PHP 5.6)
  • 34. PHP Assignment Operators Assignment Same as... Description x = y x = y The left operand gets set to the value of the expression on the right x += y x = x + y Addition x -= y x = x - y Subtraction x *= y x = x * y Multiplication x /= y x = x / y Division x %= y x = x % y Modulus
  • 35. PHP Comparison Operators Operator Name Example Result == Equal $x == $y Returns true if $x is equal to $y === Identical $x === $y Returns true if $x is equal to $y, and they are of the same type != Not equal $x != $y Returns true if $x is not equal to $y <> Not equal $x <> $y Returns true if $x is not equal to $y !== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not of the same type > Greater than $x > $y Returns true if $x is greater than $y < Less than $x < $y Returns true if $x is less than $y >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y
  • 36. PHP Increment / Decrement Operators Operator Name Description ++$x Pre-increment Increments $x by one, then returns $x $x++ Post-increment Returns $x, then increments $x by one --$x Pre-decrement Decrements $x by one, then returns $x $x-- Post-decrement Returns $x, then decrements $x by one
  • 37. PHP Logical Operators Operator Name Example Result and And $x and $y True if both $x and $y are true or Or $x or $y True if either $x or $y is true xor Xor $x xor $y True if either $x or $y is true, but not both && And $x && $y True if both $x and $y are true || Or $x || $y True if either $x or $y is true ! Not !$x True if $x is not true
  • 38. PHP String Operators Operator Name Example Result . Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2 .= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1
  • 39. PHP Array Operators Operator Name Example Result + Union $x + $y Union of $x and $y == Equality $x == $y Returns true if $x and $y have the same key/value pairs === Identity $x === $y Returns true if $x and $y have the same key/value pairs in the same order and of the same types != Inequality $x != $y Returns true if $x is not equal to $y <> Inequality $x <> $y Returns true if $x is not equal to $y !== Non-identity $x !== $y Returns true if $x is not identical to $y
  • 40. PHP Conditional Statements  In PHP we have the following conditional statements:  if statement - executes some code only if a specified condition is true  if...else statement - executes some code if a condition is true and another code if the condition is false  if...elseif....else statement - specifies a new condition to test, if the first condition is false  switch statement - selects one of many blocks of code to be executed
  • 41. If...elseif…else Statement  <?php $t = 12; if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 42. Switch Statement  <?php $favcolor = "red"; switch ($favcolor) { case "red": echo "Your favorite color is red!"; break; case "blue": echo "Your favorite color is blue!"; break; case "green": echo "Your favorite color is green!"; break; default: echo "Your favorite color is neither red, blue, or green!"; } ?>
  • 43. PHP Loops  In PHP, we have the following looping statements:  while - loops through a block of code as long as the specified condition is true  do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true  for - loops through a block of code a specified number of times  foreach - loops through a block of code for each element in an array
  • 44. The PHP while Loop  <?php $x = 1; while($x <= 5) { echo "The number is: $x <br>"; $x++; } ?>
  • 45. The PHP do...while Loop  <?php $x = 1; do { echo "The number is: $x <br>"; $x++; } while ($x <= 5); ?>
  • 46. The PHP for Loops  The PHP for Loop  <?php for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; } ?>  The PHP foreach Loop  <?php $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { echo "$value <br>"; } ?>
  • 47. PHP Functions  PHP User Defined Functions  A function is a block of statements that can be used repeatedly in a program.  A function will not execute immediately when a page loads.  A function will be executed by a call to the function.  <?php function writeMsg() { echo "Hello world!"; } writeMsg(); // call the function ?>
  • 48. PHP Function Arguments  <?php function familyName($fname, $year) { echo "$fname Stilinski Born in $year <br>"; } familyName("Hege", "1975"); familyName("Stale", "1978"); familyName("Kai Jim", "1983"); ?>
  • 49. PHP Default Argument Value  <?php function setHeight($minheight = 50) { echo "The height is : $minheight <br>"; } setHeight(350); setHeight(); // will use the default value of 50 setHeight(135); setHeight(80); ?>
  • 50. PHP Functions - Returning values  <?php function sum($x, $y) { $z = $x + $y; return $z; } echo "5 + 10 = " . sum(5, 10) . "<br>"; echo "7 + 13 = " . sum(7, 13) . "<br>"; echo "2 + 4 = " . sum(2, 4); ?>
  • 51. PHP Arrays  In PHP, there are three types of arrays:  Indexed arrays - Arrays with a numeric index  Associative arrays - Arrays with named keys  Multidimensional arrays - Arrays containing one or more arrays
  • 52. PHP Indexed Arrays  <?php $cars = array("Volvo", "BMW", "Toyota"); OR $cars[0] = “Volvo”; $cars[1] = “BMW”; $cars[2] = “Toyota”; echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; ?>  The Length of an Array - The count() Function  count($cars);
  • 53. PHP Indexed Arrays  <?php $cars = array("Volvo", "BMW", "Toyota"); OR $cars[0] = “Volvo”; $cars[1] = “BMW”; $cars[2] = “Toyota”; $arrlength = count($cars); for($x = 0; $x < $arrlength; $x++) { echo $cars[$x]; echo "<br>"; } ?>
  • 54. PHP Associative Arrays  <?php $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); echo "Peter is " . $age['Peter'] . " years old."; ?>  <?php $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); foreach($age as $x => $x_value) { echo "Key=" . $x . ", Value=" . $x_value; echo "<br>"; } ?>
  • 55. PHP Multidimensional Arrays  <?php $contacts = array( array( "name" => "Peter Parker", "email" => "peterparker@mail.com", ), array( "name" => "Clark Kent", "email" => "clarkkent@mail.com", ), array( "name" => "Harry Potter", "email" => "harrypotter@mail.com", ) ); echo "Peter Parker's Email-id is: " . $contacts[0]["email"]; print_r($contact); var_dump($cities);
  • 56. PHP Multidimensional Arrays  $favorites = array( "Dave Punk" => array( "mob" => "5689741523", "email" => "davepunk@gmail.com", ), "Dave Punk" => array( "mob" => "2584369721", "email" => "montysmith@gmail.com", ), "John Flinch" => array( "mob" => "9875147536", "email" => "johnflinch@gmail.com", ) ); keys = array_keys($favorites); for($i = 0; $i < count($favorites); $i++) { echo $keys[$i] . "n"; foreach($favorites[$keys[$i]] as $key => $value) { echo $key . " : " . $value . "n"; } echo "n"; }
  • 57. PHP Include & Require  The include (or require) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement.  It is possible to insert the content of one PHP file into another PHP file  The include and require statements are identical, except upon failure:  require will produce a fatal error (E_COMPILE_ERROR) and stop the script  include will only produce a warning (E_WARNING) and the script will continue
  • 58. PHP Include & Require  Footer.php  <?php echo "<p>Copyright &copy; 2017-" . date("Y") . " charusat.ac.in</p>"; ?>  Index.php/home.php/dept.php  <html> <body> <h1>Welcome to my home page!</h1> <p>Some text.</p> <p>Some more text.</p> <?php include 'footer.php';?> </body> </html>
  • 59. PHP Handling Form input  GET v/s POST Method  $_GET, $_POST, $_REQUEST