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
This document provides an overview of PHP including basic syntax, variables, data types, echo and print statements, operators, and string functions. PHP is an open-source server-side scripting language used for web development. Key points covered include that PHP scripts are executed on the server, variables store and manipulate data, and operators are used to perform operations on variables and values.
This document provides an overview of PHP including:
- Basic PHP syntax like variables, data types, operators, and control structures
- Functions - both built-in and user-defined, including arguments and return values
- Loops - while, do-while, for, foreach
- Object-oriented concepts like classes, objects, constructors, inheritance
- Arrays - indexed, associative, and multidimensional
- Strings and math functions
- An introduction to abstraction and object-oriented programming principles in PHP
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 ...
The document discusses various types of expressions and operators in PHP. It describes expressions as bits of PHP code that evaluate to a value, including literal values and variables. Operators take operands and perform operations on them, such as arithmetic, comparison, logical, bitwise, and string operators. It provides examples of using different operators in PHP code and explains concepts like operator precedence, associativity, and type casting.
The document discusses PHP concepts including:
- PHP is a server-side scripting language used for web development and can be used as an alternative to Microsoft ASP.
- XAMPP is an open-source cross-platform web server bundle that can be used to test PHP scripts locally.
- PHP has different data types including strings, integers, floats, booleans, and arrays.
- PHP includes various operators, conditional statements like if/else, and loops like while and foreach to control program flow.
- Functions allow code reusability and modularity in PHP programs. Built-in and user-defined functions are discussed.
- Arrays are a special variable type that can hold multiple values,
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 and overview of PHP, including:
- PHP is a server-side scripting language used for web development and can be embedded into HTML. It is commonly used to manage dynamic content, databases, sessions, and build ecommerce sites.
- Common uses of PHP include handling forms, accessing and modifying database elements, setting and accessing cookies, and restricting user access to website pages.
- The document then covers PHP syntax, variables, operators, conditional statements, loops, and arrays to provide the basic building blocks of the language.
This document provides an introduction to PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses three-tiered websites, server-side scripting, and some key aspects of PHP including its history, basic syntax, variables, data types, functions, and conditional statements. PHP allows for dynamic content generation, computational processing, database access, and more on the server side to create interactive websites and web applications.
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.
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 discusses PHP, including introducing PHP and its basic syntax, data types, operators, arrays, and array manipulation. Key points covered include:
- PHP is a popular server-side scripting language that is free and open-source
- PHP code is enclosed within <?php ?> tags
- Variables start with $, types include integers, strings, arrays
- Operators like +, -, *, / can be used, and arrays store multiple elements that can be accessed by index
- Arrays can be created and values assigned in different ways, then iterated through to output elements
This document provides an introduction to PHP (Hypertext Preprocessor), which is a popular open-source scripting language used for web development. It discusses some basic PHP concepts like scripting delimiters, variables, data types, operators, and arrays. It also covers string processing functions like strcmp() for comparing strings, and regular expressions which allow pattern matching in strings using functions like ereg() and preg_match(). The document contains code examples to demonstrate various PHP features.
Vision academy classes bcs_bca_bba_sybba_phpsachin892777
The document provides an overview of the PHP programming language. It discusses what PHP is, its features, basic syntax, variables, data types, operators, conditional statements, loops, forms handling, functions, and variable scopes. Some key points covered include:
- PHP is a server-side scripting language used for web development that allows embedding code into HTML pages.
- It is cross-platform, open source, and compatible with many servers.
- Basic PHP syntax involves wrapping code within <?php ?> tags.
- Variables start with $ and are case-sensitive. Common data types include integers, floats, booleans, strings, arrays, and objects.
- Operators include arithmetic, comparison, logical
This document provides an overview of PHP chapter 26 from a textbook. It discusses PHP data types, operators, arrays, string processing, and regular expressions. Key points covered include PHP syntax and scripting delimiters, variable declaration and data types, arithmetic operators and assignment operators, using arrays and iterating through arrays, comparing strings using the strcmp function, and processing form data and connecting to databases with PHP.
This Operator's Manual is intended as a guide for the correct use and maintenance of the machine. Therefore, study it carefully before starting and operating the machine, or before carrying out any preventive maintenance.Keep the manual in the cab so that it always is at hand. Replace it immediate if it is lost.The manual describes the applications for which the machine primarily is intended and is written to apply for all markets. We therefore ask you to disregard the sections which are not applicable to your machine or to the work for which you use your machine.
This operator's manual is intended as a guide for the correctuse and maintenance of the machine. Read this manualcarefully before you start and move the machine or before youcarry out any preventive maintenance.Keep this manual in the lockable storage compartment so thatit is always available for easy reference. Replace itimmediately if it is lost.The operator's manual describes the applications for which themachine was primarily designed. It has been written to be validon all markets. Therefore, please ignore any sections whichdo not relate to your machine or to the work that you do withyour machine.NOTE!If the manual covers more than one machine, the informationrelates to all machines unless otherwise specified.
More Related Content
Similar to PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n (20)
The document discusses PHP concepts including:
- PHP is a server-side scripting language used for web development and can be used as an alternative to Microsoft ASP.
- XAMPP is an open-source cross-platform web server bundle that can be used to test PHP scripts locally.
- PHP has different data types including strings, integers, floats, booleans, and arrays.
- PHP includes various operators, conditional statements like if/else, and loops like while and foreach to control program flow.
- Functions allow code reusability and modularity in PHP programs. Built-in and user-defined functions are discussed.
- Arrays are a special variable type that can hold multiple values,
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 and overview of PHP, including:
- PHP is a server-side scripting language used for web development and can be embedded into HTML. It is commonly used to manage dynamic content, databases, sessions, and build ecommerce sites.
- Common uses of PHP include handling forms, accessing and modifying database elements, setting and accessing cookies, and restricting user access to website pages.
- The document then covers PHP syntax, variables, operators, conditional statements, loops, and arrays to provide the basic building blocks of the language.
This document provides an introduction to PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses three-tiered websites, server-side scripting, and some key aspects of PHP including its history, basic syntax, variables, data types, functions, and conditional statements. PHP allows for dynamic content generation, computational processing, database access, and more on the server side to create interactive websites and web applications.
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.
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 discusses PHP, including introducing PHP and its basic syntax, data types, operators, arrays, and array manipulation. Key points covered include:
- PHP is a popular server-side scripting language that is free and open-source
- PHP code is enclosed within <?php ?> tags
- Variables start with $, types include integers, strings, arrays
- Operators like +, -, *, / can be used, and arrays store multiple elements that can be accessed by index
- Arrays can be created and values assigned in different ways, then iterated through to output elements
This document provides an introduction to PHP (Hypertext Preprocessor), which is a popular open-source scripting language used for web development. It discusses some basic PHP concepts like scripting delimiters, variables, data types, operators, and arrays. It also covers string processing functions like strcmp() for comparing strings, and regular expressions which allow pattern matching in strings using functions like ereg() and preg_match(). The document contains code examples to demonstrate various PHP features.
Vision academy classes bcs_bca_bba_sybba_phpsachin892777
The document provides an overview of the PHP programming language. It discusses what PHP is, its features, basic syntax, variables, data types, operators, conditional statements, loops, forms handling, functions, and variable scopes. Some key points covered include:
- PHP is a server-side scripting language used for web development that allows embedding code into HTML pages.
- It is cross-platform, open source, and compatible with many servers.
- Basic PHP syntax involves wrapping code within <?php ?> tags.
- Variables start with $ and are case-sensitive. Common data types include integers, floats, booleans, strings, arrays, and objects.
- Operators include arithmetic, comparison, logical
This document provides an overview of PHP chapter 26 from a textbook. It discusses PHP data types, operators, arrays, string processing, and regular expressions. Key points covered include PHP syntax and scripting delimiters, variable declaration and data types, arithmetic operators and assignment operators, using arrays and iterating through arrays, comparing strings using the strcmp function, and processing form data and connecting to databases with PHP.
This Operator's Manual is intended as a guide for the correct use and maintenance of the machine. Therefore, study it carefully before starting and operating the machine, or before carrying out any preventive maintenance.Keep the manual in the cab so that it always is at hand. Replace it immediate if it is lost.The manual describes the applications for which the machine primarily is intended and is written to apply for all markets. We therefore ask you to disregard the sections which are not applicable to your machine or to the work for which you use your machine.
This operator's manual is intended as a guide for the correctuse and maintenance of the machine. Read this manualcarefully before you start and move the machine or before youcarry out any preventive maintenance.Keep this manual in the lockable storage compartment so thatit is always available for easy reference. Replace itimmediately if it is lost.The operator's manual describes the applications for which themachine was primarily designed. It has been written to be validon all markets. Therefore, please ignore any sections whichdo not relate to your machine or to the work that you do withyour machine.NOTE!If the manual covers more than one machine, the informationrelates to all machines unless otherwise specified.
This Operator's Manual is intended as a guide for the correct use and maintenance of the machine. Therefore, study it carefully before starting and operating the machine, or before carrying out any preventive maintenance.Keep the manual in the cab so that it always is at hand. Replace it immediate if it is lost.The manual describes the applications for which the machine primarily is intended and is written to apply for all markets. We therefore ask you to disregard the sections which are not applicable to your machine or to the work for which you use your machine.
Audi Won’t Start Expert Battery Diagnosis and Starting System Repair SolutionsEuropean Service Center
If your Audi won’t start, rely on our expert battery diagnosis and starting system repair solutions. From dead batteries and faulty starters to alternator issues and electrical faults, our certified technicians use advanced tools to pinpoint the problem quickly. We provide reliable repairs and replacements to get your Audi back on the road with dependable starting performance.
Download Link : https://www.heavy-equipmentmanual.com/products/download-caterpillar-308e2-mini-hyd-excavator-service-repair-manual-f8c
Unleash the full potential of your Caterpillar 308E2 mini excavator with this essential service manual. Packed with detailed diagrams, troubleshooting guides, and maintenance procedures that will empower you to tackle repairs with confidence. Don't let mechanical mysteries slow you down – master your machine and keep it dominating the worksite. Language: English Format: PDF Searchable text Bookmarks for easy navigation Instant Download After Payment
Top Driving Tips to Pass Your Driving Test with ConfidenceLucas Taylor
Ace your driving test on the first try! This infographic highlights essential tips and tricks every learner driver needs to know, from preparation to staying calm behind the wheel. Get ready to pass with flying colours!
Download Link : https://www.heavy-equipmentmanual.com/products/download-caterpillar-308e2-sr-mini-hyd-excavator-service-repair-manual-tm2
Unleash the full potential of your Caterpillar 308E2 SR mini excavator with this essential service manual. Packed with detailed diagrams, troubleshooting guides, and maintenance procedures that will empower you to tackle repairs with confidence. Don't let mechanical mysteries slow you down – master your machine and keep it dominating the worksite. Language: English Format: PDF Searchable text Bookmarks for easy navigation Instant Download After Payment
Zipaworld: Redefining the Future of Air Freight Forwarding and Digital Logisticszipaworld innovation
Zipaworld is leading the transformation of India’s logistics landscape as a forward-thinking digital logistics company. With a strong foundation in air freight forwarding, Zipaworld is evolving into a full-fledged multimodal logistics provider—integrating air, road, rail, and ocean freight to deliver seamless end-to-end solutions.
Case IH Case International 5140 Tractor Service Repair Manual.pdfService Repair Manual
This document provides a summary of service information for Case/International tractor models 5120, 5130, and 5140. It includes:
- The document provides information on the engine configuration and components. It describes th engine as a four-stroke, engine with charge air cooling and wet cylinder liners. It also describes the common rail fuel system and electronically controlled internal exhaust gas recirculation system. The document includes diagrams showing engine components and their locations.
- An index of service procedures organized by component and starting paragraph number.
- Procedures for servicing front wheel bearings, steering knuckles, tie rods and toe-in settings, and removing/reinstalling the axle main member and pivot pin for two-wheel drive tractors.
- Condensed service data tables covering general specifications, tune-up details, component sizes and clearances, fluid capacities, and dual dimension measurements.
This Operator's Manual is intended as a guide for the correct use and maintenance of the machine. Therefore, study it carefully before starting and operating the machine, or before carrying out any preventive maintenance.Keep the manual in the cab so that it always is at hand. Replace it immediate if it is lost.The manual describes the applications for which the machine primarily is intended and is written to apply for all markets. We therefore ask you to disregard the sections which are not applicable to your machine or to the work for which you use your machine.
This Operator's Manual is intended as a guide for the correct use and maintenance of the machine. Therefore, study it carefully before starting and operating the machine, or before carrying out any preventive maintenance.Keep the manual in the cab so that it always is at hand. Replace it immediate if it is lost.The manual describes the applications for which the machine primarily is intended and is written to apply for all markets. We therefore ask you to disregard the sections which are not applicable to your machine or to the work for which you use your machine.
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!