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 ...
PHP is a scripting language used for web development that allows developers to write dynamically generated web pages quickly. Key points about PHP include:
- PHP code must be contained within <?php ?> tags or <? ?> shorthand tags
- Files containing PHP code must have a .php extension
- Variables, operators, functions, and other PHP elements allow dynamic content and programming logic
- Functions can take parameters and return values
- Files and sessions allow sharing data across pages
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 i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
This document provides an introduction to PHP, including an overview of server-side scripting, the basic PHP syntax, variables, operators, control structures like conditional statements and loops, and how PHP code is processed. It explains what PHP is, how it is widely used for building dynamic websites, and the basic components needed to develop PHP applications including a web server, PHP, and a database.
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
The document outlines the goals and structure of an underground PHP session for students. The session will cover PHP basics like where to get help, best practices for coding, and fundamental programming concepts. It will not provide direct code solutions but rather explain programming concepts. The session will focus on theory over specific coding examples. Key topics to be covered include PHP basics, data types, operators, and variables. Comments, indentation, and meaningful naming are emphasized as best practices.
Unit-1 PHP Basic1 of the understanding of php.pptxAatifKhan84
This document provides an introduction and overview of PHP including:
- PHP was created in 1994 and is a widely used open source scripting language.
- PHP code is executed on the server and returns HTML to the browser.
- Common PHP file extensions are .php. PHP can generate dynamic web page content.
- The document then covers PHP variables, data types, operators, conditional and loop structures, functions, and arrays.
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.
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, 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 widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
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.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. PHP code is embedded within HTML and executed on the server before the page is sent to the browser. The document provides an introduction and overview of PHP, covering its history, syntax based on Perl and C, how PHP scripts are parsed and executed, variables, arrays, operators, control structures like if/else and loops, functions to include external files, and how PHP can be used to retrieve and display external data.
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
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 overview of PHP basics including:
- What PHP is and how it works as a server-side scripting language
- The basic structure of PHP files and how PHP code is executed
- Common PHP syntax like variables, data types, operators, conditional statements, loops, arrays, and functions
- How to handle forms and user input with the $_GET, $_POST, and $_REQUEST superglobals
- Examples of basic PHP scripts and code snippets
The document is intended as an introduction to PHP for beginners, covering the essential concepts needed to get started with the language.
The document provides an introduction to PHP, including:
- PHP is a scripting language originally designed for web pages and runs on most operating systems.
- PHP syntax is quite easy if familiar with C-type languages, and it is designed to output to browsers but can also create CLI apps.
- Variables, constants, naming conventions, data types, and basic control structures like if/else, while loops and foreach loops are discussed.
- Combining PHP with XHTML is covered, recommending using functions and an object-oriented approach.
- User input via forms is mentioned, linking to a resource on processing forms with PHP.
1. The document discusses operators and flow control in PHP including math operators, assignment operators, comparison operators, logical operators, and control structures like if/else statements, switch statements, loops, and functions.
2. Regular expressions and pattern matching are introduced as ways to validate user input data with functions like ereg(), split(), and ereg_replace(). Common patterns and character classes are explained.
3. Form validation is discussed including checking for empty fields, using custom arrays for form data, and redirecting with HTTP headers. Server variables are also described.
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.
PHP is a server-side scripting language commonly used for web development. The document provides an introduction to PHP including a brief history, how PHP scripts are parsed, variables, arrays, operators, control structures, and including external files. It discusses PHP's architecture and how scripts are executed on the server before being sent to the browser.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. Key points:
- PHP scripts are executed on the server and output HTML, JavaScript, or other code to browsers.
- PHP supports variables, arrays, functions, classes, and control structures like if/else statements.
- External data like from text files or databases can be easily incorporated into dynamic web pages using PHP.
- PHP files have a .php extension and PHP code is delimited by <?php ?> tags within HTML files or standalone PHP files.
This document provides an introduction to PHP, including an overview of server-side scripting, the basic PHP syntax, variables, operators, control structures like conditional statements and loops, and how PHP code is processed. It explains what PHP is, how it is widely used for building dynamic websites, and the basic components needed to develop PHP applications including a web server, PHP, and a database.
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
The document outlines the goals and structure of an underground PHP session for students. The session will cover PHP basics like where to get help, best practices for coding, and fundamental programming concepts. It will not provide direct code solutions but rather explain programming concepts. The session will focus on theory over specific coding examples. Key topics to be covered include PHP basics, data types, operators, and variables. Comments, indentation, and meaningful naming are emphasized as best practices.
Unit-1 PHP Basic1 of the understanding of php.pptxAatifKhan84
This document provides an introduction and overview of PHP including:
- PHP was created in 1994 and is a widely used open source scripting language.
- PHP code is executed on the server and returns HTML to the browser.
- Common PHP file extensions are .php. PHP can generate dynamic web page content.
- The document then covers PHP variables, data types, operators, conditional and loop structures, functions, and arrays.
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.
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, 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 widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
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.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. PHP code is embedded within HTML and executed on the server before the page is sent to the browser. The document provides an introduction and overview of PHP, covering its history, syntax based on Perl and C, how PHP scripts are parsed and executed, variables, arrays, operators, control structures like if/else and loops, functions to include external files, and how PHP can be used to retrieve and display external data.
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
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 overview of PHP basics including:
- What PHP is and how it works as a server-side scripting language
- The basic structure of PHP files and how PHP code is executed
- Common PHP syntax like variables, data types, operators, conditional statements, loops, arrays, and functions
- How to handle forms and user input with the $_GET, $_POST, and $_REQUEST superglobals
- Examples of basic PHP scripts and code snippets
The document is intended as an introduction to PHP for beginners, covering the essential concepts needed to get started with the language.
The document provides an introduction to PHP, including:
- PHP is a scripting language originally designed for web pages and runs on most operating systems.
- PHP syntax is quite easy if familiar with C-type languages, and it is designed to output to browsers but can also create CLI apps.
- Variables, constants, naming conventions, data types, and basic control structures like if/else, while loops and foreach loops are discussed.
- Combining PHP with XHTML is covered, recommending using functions and an object-oriented approach.
- User input via forms is mentioned, linking to a resource on processing forms with PHP.
1. The document discusses operators and flow control in PHP including math operators, assignment operators, comparison operators, logical operators, and control structures like if/else statements, switch statements, loops, and functions.
2. Regular expressions and pattern matching are introduced as ways to validate user input data with functions like ereg(), split(), and ereg_replace(). Common patterns and character classes are explained.
3. Form validation is discussed including checking for empty fields, using custom arrays for form data, and redirecting with HTTP headers. Server variables are also described.
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.
PHP is a server-side scripting language commonly used for web development. The document provides an introduction to PHP including a brief history, how PHP scripts are parsed, variables, arrays, operators, control structures, and including external files. It discusses PHP's architecture and how scripts are executed on the server before being sent to the browser.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. Key points:
- PHP scripts are executed on the server and output HTML, JavaScript, or other code to browsers.
- PHP supports variables, arrays, functions, classes, and control structures like if/else statements.
- External data like from text files or databases can be easily incorporated into dynamic web pages using PHP.
- PHP files have a .php extension and PHP code is delimited by <?php ?> tags within HTML files or standalone PHP files.
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...Infopitaara
A Boiler Feed Pump (BFP) is a critical component in thermal power plants. It supplies high-pressure water (feedwater) to the boiler, ensuring continuous steam generation.
⚙️ How a Boiler Feed Pump Works
Water Collection:
Feedwater is collected from the deaerator or feedwater tank.
Pressurization:
The pump increases water pressure using multiple impellers/stages in centrifugal types.
Discharge to Boiler:
Pressurized water is then supplied to the boiler drum or economizer section, depending on design.
🌀 Types of Boiler Feed Pumps
Centrifugal Pumps (most common):
Multistage for higher pressure.
Used in large thermal power stations.
Positive Displacement Pumps (less common):
For smaller or specific applications.
Precise flow control but less efficient for large volumes.
🛠️ Key Operations and Controls
Recirculation Line: Protects the pump from overheating at low flow.
Throttle Valve: Regulates flow based on boiler demand.
Control System: Often automated via DCS/PLC for variable load conditions.
Sealing & Cooling Systems: Prevent leakage and maintain pump health.
⚠️ Common BFP Issues
Cavitation due to low NPSH (Net Positive Suction Head).
Seal or bearing failure.
Overheating from improper flow or recirculation.
In tube drawing process, a tube is pulled out through a die and a plug to reduce its diameter and thickness as per the requirement. Dimensional accuracy of cold drawn tubes plays a vital role in the further quality of end products and controlling rejection in manufacturing processes of these end products. Springback phenomenon is the elastic strain recovery after removal of forming loads, causes geometrical inaccuracies in drawn tubes. Further, this leads to difficulty in achieving close dimensional tolerances. In the present work springback of EN 8 D tube material is studied for various cold drawing parameters. The process parameters in this work include die semi-angle, land width and drawing speed. The experimentation is done using Taguchi’s L36 orthogonal array, and then optimization is done in data analysis software Minitab 17. The results of ANOVA shows that 15 degrees die semi-angle,5 mm land width and 6 m/min drawing speed yields least springback. Furthermore, optimization algorithms named Particle Swarm Optimization (PSO), Simulated Annealing (SA) and Genetic Algorithm (GA) are applied which shows that 15 degrees die semi-angle, 10 mm land width and 8 m/min drawing speed results in minimal springback with almost 10.5 % improvement. Finally, the results of experimentation are validated with Finite Element Analysis technique using ANSYS.
Value Stream Mapping Worskshops for Intelligent Continuous SecurityMarc Hornbeek
This presentation provides detailed guidance and tools for conducting Current State and Future State Value Stream Mapping workshops for Intelligent Continuous Security.
☁️ GDG Cloud Munich: Build With AI Workshop - Introduction to Vertex AI! ☁️
Join us for an exciting #BuildWithAi workshop on the 28th of April, 2025 at the Google Office in Munich!
Dive into the world of AI with our "Introduction to Vertex AI" session, presented by Google Cloud expert Randy Gupta.
Sorting Order and Stability in Sorting.
Concept of Internal and External Sorting.
Bubble Sort,
Insertion Sort,
Selection Sort,
Quick Sort and
Merge Sort,
Radix Sort, and
Shell Sort,
External Sorting, Time complexity analysis of Sorting Algorithms.
π0.5: a Vision-Language-Action Model with Open-World GeneralizationNABLAS株式会社
今回の資料「Transfusion / π0 / π0.5」は、画像・言語・アクションを統合するロボット基盤モデルについて紹介しています。
拡散×自己回帰を融合したTransformerをベースに、π0.5ではオープンワールドでの推論・計画も可能に。
This presentation introduces robot foundation models that integrate vision, language, and action.
Built on a Transformer combining diffusion and autoregression, π0.5 enables reasoning and planning in open-world settings.
The Fluke 925 is a vane anemometer, a handheld device designed to measure wind speed, air flow (volume), and temperature. It features a separate sensor and display unit, allowing greater flexibility and ease of use in tight or hard-to-reach spaces. The Fluke 925 is particularly suitable for HVAC (heating, ventilation, and air conditioning) maintenance in both residential and commercial buildings, offering a durable and cost-effective solution for routine airflow diagnostics.
1. Unit IV – Server-Side Processing and Scripting-PHP
2. Unit IV – Server-Side Processing and Scripting-PHP
PHP – Working principle of PHP – PHP Variables –
Constants
Operators – Flow Control and Looping – Arrays – Strings
Functions – File Handling – File Uploading – Email Basics
–
–
–
Email with attachments – PHP and HTML – Simple PHP scripts
– Databases with PHP.
3. PHP – Introduction
• Developed in 1994 by Apache Group.
• PHP: Hypertext Preprocessor.
• A server scripting language.
• Mainly used for form handling and
database
access.
and
• A powerful tool for making dynamic interactive
webpages.
4. PHP – Introduction
Advantages
• Very simple and easy to learn
• Interpreted Language
• Open source
• Platform Independent
• Can directly integrated with HTML
• Support to design dynamic web applications
• Reliable, efficient and flexible scripting language
• Provides support for file system, managing user sessions, cookies, E-mail
Management, execute the system commands, create directories, etc.,
5. PHP – Introduction
Syntax
The code must be enclosed with in:
<?php
// Statements (or) Codes
?>
• If anyone wants to refer file then “inlude” construct is
used.
Example: Include(“myfile.html”)
Comments
// 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
*/
6. Working Principle of PHP
• The most popular way of installing PHP is using XAMPP.
• XAMPP is a free distribution package that makes it easy
to
Web Server, MySQL, PHP, PEAR.
1. Go to the site: https://www.apachefriends.org/index.html
install Apache
2. Click on download XAMPP for Windows or Linux depending on the OS
3. When prompted for the download, click “Save” and wait for the download
finish.
4. Install the program and click on “Run”. Accept default settings by clicking
“Next” button. Finally, installation completion message is displayed.
5. On the drive, the XAMPP folder will be created. Click on xampp_start
file, this will enable to start Apache, MySQL and Tomcat start.
7. Working Principle of PHP
6. The control panel for XAMPP will looklike this,
6. Write a PHP script and save it in C:XAMPPhtdocsphp-examples
by giving the filename and extension as .php.
folder
7. Open the web browser and type http://localhost/php-
examples/filename.php.
8. The web application will be executed within the web
browser.
8. PHP – Variables
• Variables are the entities that are used for storing the
values.
• PHP is a dynamically typed language.
• Syntax: $variable_name = value;
• If the value is not assigned to the variable then they
NULL.
• Rules for Variables:
– The variable must start with letter or underscore _.
– It consists of alphanumeric characters or underscore.
– There should not be space in the name of the variable.
– While assigning the values to the variable the variable
– Example: $marks = 100;
by default the value is
must start with the $.
9. PHP – Data Types
• Four scalar data types used in PHP.
• Integer: To display the integer value. The size is 32 bits.
• Boolean: Only two types of values TRUE and FALSE.
• Double: To display the real values. It includes the number with
decimal
point, exponentiation or both.
• String: The string literals can be defined using either single or double
quotes.
10. PHP – Constants
• Constant is an identifier that contains some value.
• Once the constant value is assigned to this identifier it does not get
changed.
• The constant identifiers are specified in upper case.
• The valid constant name must start with letter or underscore.
• Use define function to assign value to the constant.
Example:
<?php
define(“MYVALUE”, “10”); echo
MYVALUE; define(“1MYVALUE”,
“something”); echo 1MYVALUE;
?>
11. PHP – print Vs. echo
• print: Function used to create simple unformatted
Example:
print “Hello <b> World!!! </b>”
print (100);
<?php
print "<h2>PHP !</h2>";
print "Hello World!<br>";
?>
output.
12. PHP – print Vs.
• echo: Simple statement that can be used with
Example:
echo “Hello <b> World!!! </b>”
$a – 10;
echo $a;
echo
or without
parenthesis.
print in PHP echo in PHP
Print can only output one string Echo can output one or more strings
Print is slower than echo Echo is faster than print
Print always return 1 Echo does not return any value
13. PHP – Operators
Arithmetic Operators
Operator Name Example Explanation
+ Addition $a + $b Sum of operands
- Subtraction $a - $b Difference of operands
* Multiplication $a * $b Product of operands
/ Division $a / $b Quotient of operands
% Modulus $a % $b Remainder of operands
** Exponentiation $a ** $b $a raised to the power $b
14. PHP
Operators
– Operators
Relational
same data type
not of same data type
Operator Name Example Explanation
== Equal $a == $b Return TRUE if $a is equal to $b
=== Identical $a === $b
Return TRUE if $a is equal to $b, and they are of
!== Not identical $a !== $b
Return TRUE if $a is not equal to $b, and they are
!= Not equal $a != $b Return TRUE if $a is not equal to $b
<> Not equal $a <> $b Return TRUE if $a is not equal to $b
< Less than $a < $b Return TRUE if $a is less than $b
<= Less than or equal to $a <= $b Return TRUE if $a is less than or equal $b
>= Greater than or equal to $a >= $b Return TRUE if $a is greater than or equal $b
<=> Spaceship $a <=>$b
Return -1 if $a is less than $b
Return 0 if $a is equal $b
Return 1 if $a is greater than $b
15. PHP – Operators
Bitwise Operators
to 1, otherwise 0.
to 1
to 0.
0 are set to 1
steps
number of places
Operator Name Example Explanation
& And $a & $b
Bits that are 1 in both $a and $b are set
| Or (Inclusive or) $a | $b
Bits that are 1 in either $a or $b are set
^ Xor (Exclusive or) $a ^ $b
Bits that are 1 in either $a or $b are set
~ Not ~$a
Bits that are 1 set to 0 and bits that are
<< Shift left $a << $b
Left shift the bits of operand $a $b
>> Shift right $a >> $b
Right shift the bits of $a operand by $b
16. PHP –
Incrementing/
Decrementing
Operators
Operators
return $a
$a by one
return $a
$a by one
Operator Name Example Explanation
++ Increment
++$a
Increment the value of $a by one, then
$a++
Return $a, then increment the value of
-- decrement
--$a
Decrement the value of $a by one, then
$a--
Return $a, then decrement the value of
17. PHP – Operators
Logical Operators
but not both
true
Operator Name Example Explanation
and AND $a and $b Return TRUE if both $a and $b are true
or OR $a or $b Return TRUE if either $a or $b is true
xor XOR $a xor $b
Return TRUE if either $ or $b is true
! NOT ! $a Return TRUE if $a is not true
&& AND $a && $b
Return TRUE if either $a and $b are
|| OR $a || $b Return TRUE if either $a or $b is true
18. PHP – Operators
Assignment Operators
to the left operand.
Operator Name Example Explanation
= Assign $a = $b
The value of right operand is assigned
+= Add then Assign $a += $b Addition same as $a = $a + $b
-= Subtract then Assign $a -= $b Subtraction same as $a = $a - $b
*=
Multiply then
Assign
$a *= $b Multiplication same as $a = $a * $b
/=
Divide then Assign
(quotient)
$a /= $b Find quotient same as $a = $a / $b
%=
Divide then Assign
(remainder)
$a %= $b Find remainder same as $a = $a % $b
19. PHP – Operators
String Operators
$a . $b
Operator Name Example Explanation
. Concatenation $a . $b Concatenate both $a and $b
.=
Concatenation and
Assignment
$a .= $b
First concatenate $a and $b, then assign
the concatenated string to $a, e.g. $a =
20. PHP – Operators
Array Operators
key/value pair
Operator Name Example Explanation
+ Union $a + $y Union of $a and $b
== Equality $a == $b
Return TRUE if $a and $b have same
!= Inequality $a != $b Return TRUE if $a is not equal to $b
=== Identity $a === $b
Return TRUE if $a and $b have same
key/value pair of same type in same
order
!== Non-Identity $a !== $b Return TRUE if $a is not identical to $b
<> Inequality $a <> $b Return TRUE if $a is not equal to $b
21. PHP – Flow Control and Looping
else
break;
Statement Syntax
if-else
if (condition)
statement;
statement;
Switch…Case
switch(expression) {
case 1:statements
break;
case 2: statements
….
default: statements
}
break: break;
continue: continue;
22. PHP – Flow Control and Looping
Statement Syntax
while
while(condition) {
statements;
}
do…while
do {
Statements;
}
while(conditio
n);
for
for(initialization; condition; increment){
Statements;
}
foreach Used to iterate through all the elements of array.
23. PHP – Arrays
• Array is a collection of similar type of elements, but in PHP
you the elements of mixed type together in single array.
can have
• PHP array is an orderedmap (contains value on the basis of key).
PHP Array
Types
1. Indexed Array
2. Associative Array
3. Multidimensional Array
24. PHP – Arrays
Indexed Array:
PHP index is represented by number which starts from 0.
Use to store number, string and object in the PHP array.
All PHP array elements are assigned to an index number by
default.
Example
<?php
$season=array("summer","winter","spring","autumn");
echo "Season are: $season[0], $season[1], $season[2] and $season[3]";
?>
26. PHP – Arrays
Associative Array
• Associative arrays are the arrays with named keys.
• It is a kind of array with name and value pair.
• Can associate name with each array elements in PHP using => symbol
Example:
$salary=array("Sonoo"=>"350000","John"=>"450000","Kartik"=>"200000");
(OR)
$salary["Sonoo"]="350000";
$salary["John"]="450000";
$salary["Kartik"]="200000";
27. PHP – Arrays
Multidimensional Array
• PHP multidimensional array
also known as array of arrays.
• It allows to store tabular data
an array.
Example
<?php
$emp = array (
array(1,"sonoo",400000),
array(2,"john",500000),
array(3,"rahul",300000)
);
for ($row = 0; $row < 3; $row++) {
for ($col = 0; $col < 3; $col++) {
echo $emp[$row][$col]." ";
}
echo "<br/>";
}
?>
is
in
• PHP multidimensional array can
be represented in the form
matrix which is represented
row * column.
of
by
28. PHP – Arrays
become the variable values
successful.
Function Purpose
extract($arr)
The array keys becomes the variable name and the array values
implode($arr) Converts array into string
explode(delimiter, str1,limit) Splits a string
array_flip($arr) Used to exchange the keys with their associated values in array
current($arr), next($arr) Traversing the array
sort(($arr) Sort arrays in ascending order
rsort($arr) Sort arrays in descending order
asort($arr) Sort associative arrays in ascending order, according to the value
ksort($arr) Sort associative arrays in ascending order, according to the key
array_change_key_case($arr,
CASE_CASENAME) Changes the case of all key of an array
array_chunk(($arr, value) Splits array into chunks
array_reverse($arr) Returns an array containing elements in reversed order
count($arr) Counts all elements in an array
array_search(”target",$arr)
Searches the specified value in an array. It returns key if search is
29. PHP – Strings
• PHP string is a sequence of characters i.e.,
used to store and manipulate text.
Example
<?php
$str1="Hello World";
$str2="Using double "quote" with backslash inside double quoted
string";
$str3="Using escape sequences n in double quoted string";
echo "$str1 <br/> $str2 <br/> $str3";
?>
30. PHP – Strings
of the string.
Function Purpose
strlen(str1) Used to return the length of a string.
strcmp(str1, str2) Compares the two strings
strtolower(str1) Converts the string to lower case
strtoupper(str1) Converts the string to upper case
trim(str1)
Remove whitespace or other characters from the beginning and end
str_split(str1) Used to split a string into an array
strrev(str1) Used to reverse the string
substr( str1, start, length ) Return the part of a string
str_word_count(str1) Returns the number of words in the string
strpos(str1, str2) Searches for a specific text within a string
str_replace(str1, str2) Replaces some characters with some other characters in a string
31. PHP – Functions
• PHP function is a piece of code that can be reused
many
• It can take input as argument list and return value.
Syntax:
times.
function functionname(){
//code to be executed
}
32. PHP – File Handling
• PHP File System allows us to create file, read file line by line, read
file character by character, write file, append file, delete file and close file.
• Syntax:
<?php
$handle = fopen("c:folderfile.txt", "r"); //open file in read
$contents = fread($handle, filesize($filename)); //read file
$fp = fopen('data.txt', 'w’); //open file in write mode
fwrite($fp, 'hello ');
fwrite($fp, 'php file');
unlink('data.txt’); //delete file
fclose($handle);
mode
?>
33. PHP – File
fopen() function is
Handling
used to open file
• PHP Open File: or URL and returns
resource.
truncates the file to zero length. If file is not found, it creates a new file.
truncates the file to zero length. If file is not found, it creates a new file.
found, it creates a new file.
found, it creates a new file.
file. If file is found, fopen() function returns FALSE.
Mode Description
r Opens file in read-only mode. It places the file pointer at the beginning of the file.
r+ Opens file in read-write mode. It places the file pointer at the beginning of the file.
w
Opens file in write-only mode. It places the file pointer to the beginning of the file and
w+
Opens file in read-write mode. It places the file pointer to the beginning of the file and
a
Opens file in write-only mode. It places the file pointer to the end of the file. If file is not
a+
Opens file in read-write mode. It places the file pointer to the end of the file. If file is not
x
Creates and opens file in write-only mode. It places the file pointer at the beginning of the
x+ It is same as x but it creates and opens file in read-write mode.
c
Opens file in write-only mode. If the file does not exist, it is created. If it exists, it is neither
truncated (as opposed to 'w'), nor the call to this function fails (as is the case with 'x'). The
file pointer is positioned on the beginning of the file
c+ It is same as c but it opens file in read-write mode.
34. PHP – File Uploading
• PHP file upload features allows to upload binary and text
files.
• One can have the full control over the file to be uploaded through PHP
authentication and file operation functions.
was stored on the server.
• move_uploaded_file(): Moves the uploaded file to a new location. The
move_uploaded_file() function checks internally if the file is uploaded thorough the
POST request. It moves the file if it is uploaded through the POST request.
$_FILES['filename']['name'] Returns file name
$_FILES['filename']['type'] Returns MIME type of the file
$_FILES['filename']['size'] Returns size of the file (in bytes)
$_FILES['filename']['tmp_name']
Returns temporary file name of the file which
$_FILES['filename']['error'] Returns error code associated with this file
35. PHP – Email Basics, Attachments
• PHP has mail()function which is useful in sending the mail from
the script.
• Syntax:
mail (to, subject, message, headers, parameters)
Where,
to à Represents the address of receiver
subject à Specifies the subject of mail
message à Defines the message which is to be sent
header à This is optional and specifies the additional headers like Cc, Bcc
parameters à This is optional and specifies the additional parameters