This document provides an overview of PHP syntax, variables, data types, operators, and other basic concepts. PHP scripts begin with <?php and end with ?>, variables start with $ and have naming rules, and there are different data types including string, integer, float, boolean, array, object and NULL. Operators allow performing actions on variables like arithmetic, comparison, increment/decrement, logical, string and array operations.
This document provides an overview of PHP (Hypertext Preprocessor) including its introduction, syntax, variables, data types, operators, control flow statements and functions. PHP is a widely used open source scripting language that allows developers to execute code server-side to generate dynamic web page content. Some key points covered include:
- PHP code is placed within <?php ?> tags in HTML documents and executed on the server.
- It supports common data types like strings, integers, arrays and objects that can be stored and manipulated using variables and operators.
- Control structures allow conditional execution and loops like if/else, switch, while, do/while and for to control program flow.
- Functions
The document discusses various types of operators in PHP including arithmetic, assignment, comparison, increment/decrement, logical, string, and array operators. It provides examples of common operators like addition, subtraction, equality checking, concatenation and describes what each operator does.
Variables are containers that store information in PHP. PHP variables are case sensitive and can contain strings, integers, floats, Booleans, arrays and objects. Variables start with a $ sign followed by a name. Variable names must begin with a letter or underscore and can contain alphanumeric characters and underscores. Variables can be assigned values using common operators like assignment, addition, subtraction etc. Variables can have different scopes like local, global and static. Constants are similar to variables but their values cannot be changed once defined.
PHP is a server-side scripting language used for web development. It allows developers to write scripts that can create dynamic web page content. Some key uses of PHP include server-side scripting, command line scripting, and writing desktop applications. The document discusses various PHP concepts like data types, variables, constants, expressions, and operators. It provides examples to illustrate PHP syntax and how different PHP elements work.
PHP is one of the simplest server-side languages out there, and it was designed primarily for web development. Learning PHP is good not only because it adds ...
1) The document provides an introduction to PHP basics including variables, data types, operators, and form handling. It explains how to store data in variables, assign values, destroy variables, and inspect variable contents.
2) Various PHP data types are covered such as integers, floats, strings, booleans, and NULL. Arithmetic, comparison, logical and assignment operators are also explained.
3) The document demonstrates how to manipulate variables using operators, perform arithmetic operations, concatenate strings, compare variables, and perform logical tests.
The document provides an introduction to PHP by discussing what PHP is, the basic syntax, variables, data types, operators, and control structures in PHP. PHP is a server-side scripting language used for web development that allows embedding scripts into HTML. The basic syntax uses <?php ?> tags to escape HTML. PHP supports variables, arrays, and basic data types like integers, floats, strings, booleans, and NULL. Operators include arithmetic, assignment, comparison, and logical operators. Control structures include if/else statements, while loops, for loops, and switch statements.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
This document provides an introduction to PHP and MySQL. It begins by stating the goal is to provide basic PHP knowledge and code explanations. It then discusses what PHP is, including that it is an open-source scripting language used to generate dynamic web pages. Several PHP basics are covered, such as variables, functions, includes, forms, and sessions. The document concludes with an overview of PHP, noting its ease of use, large function library, ability to output various file types, and support for many databases. Examples are provided throughout to demonstrate PHP concepts.
This document provides an introduction to PHP and MySQL. It begins by stating the goal is to provide basic PHP knowledge and code explanations. It then discusses what PHP is, including that it is an open-source scripting language used to generate dynamic web pages. Several PHP basics are covered, such as variables, functions, include files, forms, and sessions. The document concludes with an overview of PHP, noting its ease of use, large function library, ability to output different file types, and support for many databases.
This document provides an introduction and overview of PHP, including what PHP is, what is needed to use it, basic syntax, variables, data types, operators, control structures like if/else and loops, functions, and includes/requires. Key points covered include PHP being a server-side scripting language, basic syntax using <?php ?> tags, common variable types and scoping, operators for arithmetic, comparison and logic, and common control structures for conditional execution and repetition.
PHP is a server-side scripting language commonly used for web development. It allows creation of dynamic content and applications. Some key things PHP can do include building shopping carts, content management systems, forums, and other web applications. PHP code is processed on the server and the results are sent to the user's browser. Variables, arrays, and other data types can store and manipulate information. Control structures like if/else statements and loops allow conditional execution of code. Functions allow reusable blocks of code to be defined. Sessions allow storing of data across multiple pages for a user.
This document provides an introduction and overview of PHP and MySQL for beginners. It discusses:
- What PHP is and how it is used to generate dynamic web pages by embedding PHP scripts in HTML.
- Key PHP concepts like variables, data types, echo, comments, functions, and control structures like if/else statements.
- How to connect to and query MySQL databases from PHP scripts using functions like mysql_connect().
- Additional PHP features like forms, sessions, includes and how to avoid common errors when using sessions.
The tutorial is intended to provide just enough PHP and MySQL knowledge to get started developing basic dynamic web applications that interface with databases.
The document provides an introduction to PHP including PHP tags, comments, data types, variables, control structures, functions and more. It explains that PHP code is placed between <?php ?> tags and describes the different tags like <?php ?> for PHP code, <!-- --> for HTML comments. It also summarizes key PHP concepts like variables, arrays, strings, operators, if/else statements, loops, functions and built-in PHP functions.
PHP Basics
This document provides an overview of PHP basics including comments, constants, data types, variables, output functions, superglobals, here documents, operators, and references. It discusses the syntax and usage of PHP comments, defines constants, lists the main data types, explains how to declare variables, compares print and echo output functions, outlines common superglobal variables, demonstrates here documents, and covers unary, arithmetic, assignment, comparison, logical, and ternary operators as well as references.
The document provides an introduction to PHP including what PHP is, the basic syntax, variable types, operators, control structures like if/else and loops, and functions. PHP is a server-side scripting language used for web development that is embedded into HTML. It requires a web server with PHP enabled and uses <?php ?> tags. The document outlines the basic building blocks of PHP like variables, data types, operators, and control flow structures.
This document provides an introduction to the PHP programming language. It discusses PHP's syntax which is inspired by C with curly braces and semicolons, and Perl with dollar signs for variables and associative arrays. PHP code can be embedded within HTML files to dynamically output content. The document also covers PHP variables, data types, expressions, operators, control structures like if/else statements, and functions like echo to output values.
Thea Yagerlener, Senior Program Manager at IREC, gave this presentation at the Forth Building EV-ready Communities to Accelerate Adoption webinar on May 13, 2025.
Ad
More Related Content
Similar to PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n (20)
The document provides an introduction to PHP by discussing what PHP is, the basic syntax, variables, data types, operators, and control structures in PHP. PHP is a server-side scripting language used for web development that allows embedding scripts into HTML. The basic syntax uses <?php ?> tags to escape HTML. PHP supports variables, arrays, and basic data types like integers, floats, strings, booleans, and NULL. Operators include arithmetic, assignment, comparison, and logical operators. Control structures include if/else statements, while loops, for loops, and switch statements.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
This document provides an introduction to PHP and MySQL. It begins by stating the goal is to provide basic PHP knowledge and code explanations. It then discusses what PHP is, including that it is an open-source scripting language used to generate dynamic web pages. Several PHP basics are covered, such as variables, functions, includes, forms, and sessions. The document concludes with an overview of PHP, noting its ease of use, large function library, ability to output various file types, and support for many databases. Examples are provided throughout to demonstrate PHP concepts.
This document provides an introduction to PHP and MySQL. It begins by stating the goal is to provide basic PHP knowledge and code explanations. It then discusses what PHP is, including that it is an open-source scripting language used to generate dynamic web pages. Several PHP basics are covered, such as variables, functions, include files, forms, and sessions. The document concludes with an overview of PHP, noting its ease of use, large function library, ability to output different file types, and support for many databases.
This document provides an introduction and overview of PHP, including what PHP is, what is needed to use it, basic syntax, variables, data types, operators, control structures like if/else and loops, functions, and includes/requires. Key points covered include PHP being a server-side scripting language, basic syntax using <?php ?> tags, common variable types and scoping, operators for arithmetic, comparison and logic, and common control structures for conditional execution and repetition.
PHP is a server-side scripting language commonly used for web development. It allows creation of dynamic content and applications. Some key things PHP can do include building shopping carts, content management systems, forums, and other web applications. PHP code is processed on the server and the results are sent to the user's browser. Variables, arrays, and other data types can store and manipulate information. Control structures like if/else statements and loops allow conditional execution of code. Functions allow reusable blocks of code to be defined. Sessions allow storing of data across multiple pages for a user.
This document provides an introduction and overview of PHP and MySQL for beginners. It discusses:
- What PHP is and how it is used to generate dynamic web pages by embedding PHP scripts in HTML.
- Key PHP concepts like variables, data types, echo, comments, functions, and control structures like if/else statements.
- How to connect to and query MySQL databases from PHP scripts using functions like mysql_connect().
- Additional PHP features like forms, sessions, includes and how to avoid common errors when using sessions.
The tutorial is intended to provide just enough PHP and MySQL knowledge to get started developing basic dynamic web applications that interface with databases.
The document provides an introduction to PHP including PHP tags, comments, data types, variables, control structures, functions and more. It explains that PHP code is placed between <?php ?> tags and describes the different tags like <?php ?> for PHP code, <!-- --> for HTML comments. It also summarizes key PHP concepts like variables, arrays, strings, operators, if/else statements, loops, functions and built-in PHP functions.
PHP Basics
This document provides an overview of PHP basics including comments, constants, data types, variables, output functions, superglobals, here documents, operators, and references. It discusses the syntax and usage of PHP comments, defines constants, lists the main data types, explains how to declare variables, compares print and echo output functions, outlines common superglobal variables, demonstrates here documents, and covers unary, arithmetic, assignment, comparison, logical, and ternary operators as well as references.
The document provides an introduction to PHP including what PHP is, the basic syntax, variable types, operators, control structures like if/else and loops, and functions. PHP is a server-side scripting language used for web development that is embedded into HTML. It requires a web server with PHP enabled and uses <?php ?> tags. The document outlines the basic building blocks of PHP like variables, data types, operators, and control flow structures.
This document provides an introduction to the PHP programming language. It discusses PHP's syntax which is inspired by C with curly braces and semicolons, and Perl with dollar signs for variables and associative arrays. PHP code can be embedded within HTML files to dynamically output content. The document also covers PHP variables, data types, expressions, operators, control structures like if/else statements, and functions like echo to output values.
Thea Yagerlener, Senior Program Manager at IREC, gave this presentation at the Forth Building EV-ready Communities to Accelerate Adoption webinar on May 13, 2025.
Charge at Home: Building EV Ready CommunitiesForth
Anna Guida, Program Manager at Forth, gave this presentation at the Forth Building EV-ready Communities to Accelerate Adoption webinar on May 13, 2025.
Zhejiang Zhongrui Auto Parts Co., Ltd., a leading automotive fastener manufacturer based in Jiaxing City, Zhejiang Province, China (Est. 1986), is pleased to announce its participation in the Ningbo International Auto Parts & Aftermarket Expo 2025 (CAPAFAIR Ningbo 2025). The event, a key hub for global sourcing of auto parts, will take place from August 13th to 15th, 2025, at the Ningbo International Conference & Exhibition Center. We invite all professional buyers, including importers, exporters, OEMs, Tier 1 & Tier 2 suppliers, and automotive aftermarket agents, to connect with our team at Booth H5-234.
Meet a few members of our dedicated team, ready to help you:
Coco Chen, Director of Business Development: coco.chen@zjzrap.com
Freddie Xiao, Account Manager: freddie.xiao@zjzrap.com
Brian Xu, Technical Sales Assistant: brian.xu@zjzrap.com
Krupp hm 1000 marathon service repair manual.pdf, Professional Service Benefits
Using a factory-approved service manual ensures accurate disassembly and reassembly, correct torque specs, and proper hydraulic settings. This is crucial for the HM 1000 Marathon, which features an automatic lubrication system and enhanced wear protection.
Whether you're a technician or operator, investing in routine service helps keep your Krupp hydraulic hammer reliable and productive.
This heavy equipment service manual provides detailed repair procedures, troubleshooting guides, and maintenance instructions for technicians and operators. It includes high-quality diagrams, technical specifications, and step-by-step instructions to ensure accurate repairs and diagnostics. Designed for professionals and DIY users alike, the manual covers everything from engine overhauls to hydraulic systems, wiring, and calibration settings. Whether you're working in the field or the shop, this manual is an essential tool to maximize performance, reduce downtime, and maintain your equipment’s reliability.
New Holland T7.270 Auto Command Tractor Service Manual.pdf, A complete heavy equipment service manual tailored for mechanics, operators, and fleet maintenance teams. This guide covers all major systems, including engine, transmission, hydraulics, electrical, and control systems. It features easy-to-follow instructions, detailed illustrations, and OEM specifications to ensure safe and effective repairs. Ideal for workshop or on-site service, the manual helps extend the lifespan of your machinery and supports preventive maintenance. Save time and avoid costly mistakes with clear, professional guidance on every page.
New Holland Boomer 25 Boomer Tractor Service Manual.pdf, Official factory manual detailing troubleshooting, diagnostics, and service routines to keep your heavy equipment running at peak performance
New Holland T7.190 Tractor Service Repair Manual.pdf, A complete heavy equipment service manual tailored for mechanics, operators, and fleet maintenance teams. This guide covers all major systems, including engine, transmission, hydraulics, electrical, and control systems. It features easy-to-follow instructions, detailed illustrations, and OEM specifications to ensure safe and effective repairs. Ideal for workshop or on-site service, the manual helps extend the lifespan of your machinery and supports preventive maintenance. Save time and avoid costly mistakes with clear, professional guidance on every page.
Kioti Daedong DK451 Tractor Service Repair Manual.pdf, Comprehensive Troubleshooting Guide
This manual provides step-by-step troubleshooting procedures to quickly diagnose and fix issues in heavy machinery with accuracy and confidence.
What Does It Mean When Your Volvo Says ‘Engine System Service Required’AutoScandia
When your Volvo displays “Engine System Service Required,” it signals a potential issue within the engine or emissions system. This warning can indicate anything from sensor faults to needed software updates or mechanical problems. Prompt professional diagnostics are essential to identify the cause, maintain performance, and prevent more serious engine damage. Don’t delay—get it checked promptly.
Discover the secrets of caterpillar machinery with our exquisite 75C Challenger operation and maintenance manual. Unleash the full potential of this powerful tool with comprehensive instructions and expert tips, making your work effortless and efficient. The perfect companion for the discerning professional.
Service Manual John Deere LX277AWS Repair.pdf, This professional-grade heavy machinery service manual is your go-to resource for efficient equipment maintenance and repair. With factory specifications, torque values, hydraulic schematics, and troubleshooting charts, it's a must-have for any technician or operator. Whether you're replacing parts, diagnosing faults, or performing routine service, this manual ensures you're equipped with accurate, model-specific procedures. Boost productivity and confidence by having all the technical knowledge you need in one place.
WA150-6 Komatsu Wheel Loader Service Repair Manual.pdf, What’s Included in the Manual (SN 80001 and up)
✅ Complete Coverage of All Major Components
Engine and cooling system
Transmission and powertrain
Hydraulic systems
Electrical circuits and wiring diagrams
Axles, brakes, and steering
Frame, cab, and body
Troubleshooting procedures
✅ Additional Features
Exploded views and diagrams for clear part identification
Torque specifications and adjustment data
Maintenance intervals and service checklists
Step-by-step disassembly and reassembly instructions
Engine New Holland Tc29da Tractors Service Manual.pdf, Official factory manual detailing troubleshooting, diagnostics, and service routines to keep your heavy equipment running at peak performance
2. P H P
• PHP is a server scripting language, and a powerful tool for making
dynamic and interactive Web pages.
What is PHP?
• 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
What is a PHP File?
• PHP files have extension ".php"
3. WHAT CAN PHP DO?
• 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
4. P H P S Y N T A X P H P C O M M E N T S
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
// Outputs a welcome message:
echo "Welcome Home!";
Multi-line Comments
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored.
5. 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
• Variable names are case-sensitive
Example- $x = 5;
$y = "John"
6. P H P VA R I A B L E S S C O P E
The scope of a variable is the part of the script where the variable can be referenced/used.
PHP has three different variable scopes:
• local
• global
• static
7. GLOBAL AND LOCAL SCOPE
• A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside
a function.
Global Scope
<?php
$x = 5; // global scope
function myTest() {
// using x inside this function will generate an error
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
echo "<p>Variable x outside function is: $x</p>";
?>
Output - Variable x inside function is:
Variable x outside function is: 5
8. LOCAL SCOPE
<?php
function myTest() {
$x = 5; // local scope
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
// using x outside the function will generate an error
echo "<p>Variable x outside function is: $x</p>";
?>
Output - Variable x inside function is: 5
Variable x outside function is:
9. P H P E C H O A N D P R I N T S T A T E M E N T S
echo and print are more or less the same.They are both used to output data to the screen.
• The differences are small: 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.
10. P H P D A T A T Y P E S
Variables can store data of different types, and different data types can do different
things.
PHP supports the following data types:
• String
• Integer
• Float (floating point numbers - also called double)
• Boolean
• Array
• NULL
11. P H P S T R I N G
A string is a sequence of characters, like "Hello world!“.
<?php
$x = "Hello world!";
$y = 'Hello world!';
var_dump($x);
echo "<br>";
var_dump($y);
?>
Output - string(12) "Hello world!"
string(12) "Hello world!"
12. P H P I N T E G E R
• An integer must have at least one digit
• An integer must not have a decimal point
• An integer can be either positive or negative
• Integers can be specified in: decimal (base 10), hexadecimal (base 16), octal (base 8), or binary
(base 2) notation
<?php
$x = 5985;
var_dump($x);
?>
Output - int(5985)
13. PHP FLOAT
• A float (floating point number) is a number with a decimal point or a number in exponential form.
• In the following example $x is a float.The PHP var_dump() function returns the data type and
value:
<?php
$x = 10.365;
var_dump($x);
?>
Output - float(10.365)
14. PHP BOOLEAN
A Boolean represents two possible states:TRUE or FALSE.
<html>
<body>
<?php
$x = true;
var_dump($x);
?>
</body>
</html>
Output - bool(true)
15. P H P A R R A Y
• An array stores multiple values in one single variable.
• In the following example $cars is an array.The PHP var_dump() function returns the data type
and value:
<?php
$cars = array("BMW","Toyota");
var_dump($cars);
?>
Output –
array(2) { [0]=> string(3) "BMW" [1]=> string(6) "Toyota" }
16. P H P C A S T I N G
Change DataType
Casting in PHP is done with these statements:
(string) - Converts to data type String
(int) - Converts to data type Integer
(float) - Converts to data type Float
(bool) - Converts to data type Boolean
(array) - Converts to data type Array
(object) - Converts to data type Object
(unset) - Converts to data type NULL
17. <?php
$a="first step";
$b="2";
$c="true";
$d="3.89";
$f="null";
$a= (string) $a;
$b= (array) $b;
$c= (bool) $c;
$d= (float) $d;
$f= (string) $f;
//To verify the type of any object in PHP, use
the var_dump() funtion:
var_du($a);
echo"<br>";
var_dump($b);
echo"<br>";
var_dump($c);
echo"<br>";
var_dump($d);
echo"<br>";
var_dump($f);
?>
OUTPUT :
string(10) "first step"
array(1) { [0]=> string(1) "2" }
bool(true)
float(3.89)
string(4) "null"
18. P H P C O N S T A N T S
• Constants are like variables, except that once they are defined they cannot be
changed or undefined.
• A constant is an identifier (name) for a simple value. The value cannot be changed
during the script.
• A valid constant name starts with a letter or underscore (no $ sign before the constant
name)
Syntax:
define(name, value, case-insensitive);
19. P H P O P E R ATO R S
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Increment/Decrement operators
• Logical operators
• String operators
• Array operators
• Conditional assignment operators
20. PHP ARITHMETIC OPERATORS
The PHP arithmetic operators are used with numeric values to perform common
arithmetical operations, such as addition, subtraction, multiplication etc.
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
21. P H P A S S I G N M E N T O P E R AT O R S
The PHP assignment operators are used with numeric values to write a value to
a variable
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
22. P H P C O M PA R I S O N O P E R ATO R S
The PHP comparison operators are used to compare two values (number or string):
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
<=> Spaceship $x <=> $y Returns an integer less than, equal to, or greater than zero,
depending on if $x is less than, equal to, or greater than $y.
Introduced in PHP 7.
23. PH P IN CR E ME N T / D E CRE M EN T O PE R ATOR S
The PHP increment operators are used to increment a variable's value.
The PHP decrement operators are used to decrement a variable's value
Operator Same as... 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
24. P H P L O G I C A L O P E R AT O R S
The PHP logical operators are used to combine conditional statements.
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
25. P H P S T R I N G O P E R AT O R S
PHP has two operators that are specially designed for strings.
Operator Name Example Result
. Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2
.= Concatenation
assignment
$txt1 .= $txt2 Appends $txt2 to $txt1
26. P H P A R R AY O P E R ATO R S
The PHP array operators are used to compare arrays.
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
27. P H P C O N D I T I O N A L A S S I G N M E N T O P E R ATO R S
The PHP conditional assignment operators are used to set a value depending on
conditions:
Operator Name Example Result
?: Ternary $x
= expr1 ? expr2 : e
xpr3
Returns the value of $x.
The value of $x is expr2 if expr1 =
TRUE.
The value of $x is expr3 if expr1 =
FALSE
?? Null coalescing $x = expr1 ?? expr2 Returns the value of $x.
The value of $x
is expr1 if expr1 exists, and is not
NULL.
If expr1 does not exist, or is NULL,
the value of $x is expr2.
28. PHP IF STATEMENTS
if statement - executes some code if one condition is true.
<?php
if (5 > 3) {
echo "Have a good day!";
}
?>
Output - Have a good day!
29. P H P I F. . . E L S E S TAT E M E N T S
The if...else statement executes some code if a condition is true and another code if that condition is
false.
<?php
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Output - Have a good day!
30. I F. . . E LS E I F. . . E LS E S TAT E ME NT
The if...elseif...else statement executes different codes for more than two conditions.
<?php
if ($t < "10") {
echo "Have a good morning!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Output - Have a good day!