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.
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
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 ...
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.
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.
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,
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
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.
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.
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.
This document provides an introduction to PHP by outlining its key topics and features. It explains that PHP can be used for server-side web development, command-line scripting, and client-side GUI applications. The document then walks through variables, data types, operators, control structures, and loops in PHP. It provides examples to illustrate PHP syntax and best practices.
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an introduction to PHP, explaining that it is a server-side scripting language used to generate HTML web pages. It discusses the differences between client-side and server-side scripting, with PHP being an example of server-side scripting. The summary also explains how to create basic PHP pages and covers some basic PHP syntax including variables, data types, operators, and control structures like if/else statements.
This document provides an overview of server-side scripting using PHP. It covers developing a PHP environment using XAMPP, the basic syntax of PHP scripts, working with forms and user input, and integrating PHP with databases. Key topics include setting up Apache and MySQL, PHP variables and data types, operators, and features for security. The document is intended to give necessary information on core PHP concepts for web development.
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.
Esoft Metro Campus - Diploma in Web Engineering - (Module VI) Fundamentals of PHP
(Template - Virtusa Corporate)
Contents:
Introduction to PHP
What PHP Can Do?
PHP Environment Setup
What a PHP File is?
PHP Syntax
Comments in PHP
echo and print Statements
PHP Variables
PHP Data Types
Changing Type by settype()
Changing Type by Casting
PHP Constants
Arithmetic Operators
String Operators
Assignment Operators
Comparison Operators
Logical Operators
Operators Precedence
If Statement
If… Else Statement
If… Else if… Else Statement
Switch Statement
The ? Operator
While Loop
Do While Loop
For Loop
break Statement
continue Statement
Functions
User Defined Functions
Functions - Returning values
Default Argument Value
Arguments as Reference
Existence of Functions
Variable Local and Global Scope
The global Keyword
GLOBALS Array
Superglobals
Static Variables
This document provides an introduction and overview of PHP and MySQL. PHP is a programming language used for building dynamic web sites. It allows embedding code within HTML pages to quickly create dynamic content. PHP is processed on the server side to produce HTML results. The document outlines PHP basics like syntax, variables, strings, operators, and conditional statements. It also discusses MySQL, the most popular database used with PHP. The document concludes with exercises for users to practice basic PHP concepts.
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 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 Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
This document provides an introduction to PHP programming. It discusses what PHP is, how to set up a PHP development environment using XAMPP, basic PHP syntax and structures, variables and data types, operators, conditional statements, arrays, and other fundamental PHP concepts. Examples are provided throughout to illustrate key points. The document is intended as a introductory guide to learning PHP for web development.
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,
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
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.
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.
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.
This document provides an introduction to PHP by outlining its key topics and features. It explains that PHP can be used for server-side web development, command-line scripting, and client-side GUI applications. The document then walks through variables, data types, operators, control structures, and loops in PHP. It provides examples to illustrate PHP syntax and best practices.
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an introduction to PHP, explaining that it is a server-side scripting language used to generate HTML web pages. It discusses the differences between client-side and server-side scripting, with PHP being an example of server-side scripting. The summary also explains how to create basic PHP pages and covers some basic PHP syntax including variables, data types, operators, and control structures like if/else statements.
This document provides an overview of server-side scripting using PHP. It covers developing a PHP environment using XAMPP, the basic syntax of PHP scripts, working with forms and user input, and integrating PHP with databases. Key topics include setting up Apache and MySQL, PHP variables and data types, operators, and features for security. The document is intended to give necessary information on core PHP concepts for web development.
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.
Esoft Metro Campus - Diploma in Web Engineering - (Module VI) Fundamentals of PHP
(Template - Virtusa Corporate)
Contents:
Introduction to PHP
What PHP Can Do?
PHP Environment Setup
What a PHP File is?
PHP Syntax
Comments in PHP
echo and print Statements
PHP Variables
PHP Data Types
Changing Type by settype()
Changing Type by Casting
PHP Constants
Arithmetic Operators
String Operators
Assignment Operators
Comparison Operators
Logical Operators
Operators Precedence
If Statement
If… Else Statement
If… Else if… Else Statement
Switch Statement
The ? Operator
While Loop
Do While Loop
For Loop
break Statement
continue Statement
Functions
User Defined Functions
Functions - Returning values
Default Argument Value
Arguments as Reference
Existence of Functions
Variable Local and Global Scope
The global Keyword
GLOBALS Array
Superglobals
Static Variables
This document provides an introduction and overview of PHP and MySQL. PHP is a programming language used for building dynamic web sites. It allows embedding code within HTML pages to quickly create dynamic content. PHP is processed on the server side to produce HTML results. The document outlines PHP basics like syntax, variables, strings, operators, and conditional statements. It also discusses MySQL, the most popular database used with PHP. The document concludes with exercises for users to practice basic PHP concepts.
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 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 Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
This document provides an introduction to PHP programming. It discusses what PHP is, how to set up a PHP development environment using XAMPP, basic PHP syntax and structures, variables and data types, operators, conditional statements, arrays, and other fundamental PHP concepts. Examples are provided throughout to illustrate key points. The document is intended as a introductory guide to learning PHP for web development.
First Review PPT gfinal gyft ftu liu yrfut goSowndarya6
CyberShieldX provides end-to-end security solutions, including vulnerability assessment, penetration testing, and real-time threat detection for business websites. It ensures that organizations can identify and mitigate security risks before exploitation.
Unlike traditional security tools, CyberShieldX integrates AI models to automate vulnerability detection, minimize false positives, and enhance threat intelligence. This reduces manual effort and improves security accuracy.
Many small and medium businesses lack dedicated cybersecurity teams. CyberShieldX provides an easy-to-use platform with AI-powered insights to assist non-experts in securing their websites.
Traditional enterprise security solutions are often expensive. CyberShieldX, as a SaaS platform, offers cost-effective security solutions with flexible pricing for businesses of all sizes.
Businesses must comply with security regulations, and failure to do so can result in fines or data breaches. CyberShieldX helps organizations meet compliance requirements efficiently.
This research presents a machine learning (ML) based model to estimate the axial strength of corroded RC columns reinforced with fiber-reinforced polymer (FRP) composites. Estimating the axial strength of corroded columns is complex due to the intricate interplay between corrosion and FRP reinforcement. To address this, a dataset of 102 samples from various literature sources was compiled. Subsequently, this dataset was employed to create and train the ML models. The parameters influencing axial strength included the geometry of the column, properties of the FRP material, degree of corrosion, and properties of the concrete. Considering the scarcity of reliable design guidelines for estimating the axial strength of RC columns considering corrosion effects, artificial neural network (ANN), Gaussian process regression (GPR), and support vector machine (SVM) techniques were employed. These techniques were used to predict the axial strength of corroded RC columns reinforced with FRP. When comparing the results of the proposed ML models with existing design guidelines, the ANN model demonstrated higher predictive accuracy. The ANN model achieved an R-value of 98.08% and an RMSE value of 132.69 kN which is the lowest among all other models. This model fills the existing gap in knowledge and provides a precise means of assessment. This model can be used in the scientific community by researchers and practitioners to predict the axial strength of FRP-strengthened corroded columns. In addition, the GPR and SVM models obtained an accuracy of 98.26% and 97.99%, respectively.
This study will provide the audience with an understanding of the capabilities of soft tools such as Artificial Neural Networks (ANN), Support Vector Regression (SVR), Model Trees (MT), and Multi-Gene Genetic Programming (MGGP) as a statistical downscaling tool. Many projects are underway around the world to downscale the data from Global Climate Models (GCM). The majority of the statistical tools have a lengthy downscaling pipeline to follow. To improve its accuracy, the GCM data is re-gridded according to the grid points of the observed data, standardized, and, sometimes, bias-removal is required. The current work suggests that future precipitation can be predicted by using precipitation data from the nearest four grid points as input to soft tools and observed precipitation as output. This research aims to estimate precipitation trends in the near future (2021-2050), using 5 GCMs, for Pune, in the state of Maharashtra, India. The findings indicate that each one of the soft tools can model the precipitation with excellent accuracy as compared to the traditional method of Distribution Based Scaling (DBS). The results show that ANN models appear to give the best results, followed by MT, then MGGP, and finally SVR. This work is one of a kind in that it provides insights into the changing monsoon season in Pune. The anticipated average precipitation levels depict a rise of 300–500% in January, along with increases of 200-300% in February and March, and a 100-150% increase for April and December. In contrast, rainfall appears to be decreasing by 20-30% between June and September.
Call For Papers - International Journal on Natural Language Computing (IJNLC)kevig
Natural Language Processing is a programmed approach to analyze text that is based on both a
set of theories and a set of technologies. This forum aims to bring together researchers who have
designed and build software that will analyze, understand, and generate languages that humans use
naturally to address computers.
Third Review PPT that consists of the project d etails like abstract.Sowndarya6
CyberShieldX is an AI-driven cybersecurity SaaS web application designed to provide automated security analysis and proactive threat mitigation for business websites. As cyber threats continue to evolve, traditional security tools like OpenVAS and Nessus require manual configurations and lack real-time automation. CyberShieldX addresses these limitations by integrating AI-powered vulnerability assessment, intrusion detection, and security maintenance services. Users can analyze their websites by simply submitting a URL, after which CyberShieldX conducts an in-depth vulnerability scan using advanced security tools such as OpenVAS, Nessus, and Metasploit. The system then generates a detailed report highlighting security risks, potential exploits, and recommended fixes. Premium users receive continuous security monitoring, automatic patching, and expert assistance to fortify their digital infrastructure against emerging threats. Built on a robust cloud infrastructure using AWS, Docker, and Kubernetes, CyberShieldX ensures scalability, high availability, and efficient security enforcement. Its AI-driven approach enhances detection accuracy, minimizes false positives, and provides real-time security insights. This project will cover the system's architecture, implementation, and its advantages over existing security solutions, demonstrating how CyberShieldX revolutionizes cybersecurity by offering businesses a smarter, automated, and proactive defense mechanism against ever-evolving cyber threats.
Characterization of Polymeric Materials by Thermal Analysis, Spectroscopy an...1SI20ME092ShivayogiB
3d Printing Nano composites As the world of technology continually drives the scientific community and the
development of innovative instrumentation, it is important for the analytical chemist to
be certain to take advantage of the wide range of knowledge that can be gained by using
multiple modes of analysis. No single instrument is capable of entirely characterizing a
material; therefore, the knowledge gained from multiple modes of analysis must be
pieced together in order to provide the most accurate description of the sample. Using a
single method only provides one dimension, but with the use of additional methods the
analysis is multi-faceted. Instrument systems are designed to gather a distinct set of
data, with no single system providing complete analysis. By coupling traditional
thermal analysis techniques such as thermogravimetric (TGA), thermomechanical
(TMA), and dynamic scanning calorimetry (DSC) with spectroscopic techniques such
as Fourier Transform Infrared (FTIR), mass spectroscopy (MS), and X-ray diffraction
(XRD), all aspects surrounding the materials physical and chemical properties can be
determined almost entirely. Specifically the importance of evolved gas analysis (EGA),
thermal-IR, XRD, and micro-thermal analysis will be discussed.
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...gerogepatton
The International Journal of Artificial Intelligence & Applications (IJAIA) is a bi monthly open access peer-reviewed journal that publishes articles which contribute new results in all areas of the Artificial Intelligence & Applications (IJAIA). It is an international journal intended for professionals and researchers in all fields of AI for researchers, programmers, and software and hardware manufacturers. The journal also aims to publish new attempts in the form of special issues on emerging areas in Artificial Intelligence and applications.
Civil engineering faces significant challenges from expansive soils, which can lead to structural damage. This study aims to optimize subtractive clustering and Fuzzy C-Mean Clustering (FCM) models for the most accurate prediction of swelling percentage in expansive soils. Two ANFIS models were developed, namely the FIS1S model using subtractive clustering and the FIS2S model utilizing the FCM algorithm. Due to the MATLAB graphical user interface's limitation on the number of membership functions, the coding approach was employed to develop the ANFIS models for optimal prediction accuracy and problem-solving time. So, two programs were created to determine the optimal influence radius for the FIS1S model and the number of membership functions for the FIS2S model to achieve the highest prediction accuracy. The ANFIS models have demonstrated their highest predictive ability in predicting swelling percentage, thanks to the optimization of membership functions and cluster centers. The developed programs also showed excellent performance and can be potentially applied to optimize subtractive clustering and FCM models in accurately modeling various engineering aspects.
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...sebastianku31
The International Journal of Software Engineering & Applications (IJSEA) is a bi-monthly open access peer-reviewed journal that publishes articles which contribute new results in all areas of the Software Engineering & Applications. The goal of this journal is to bring together researchers and practitioners from academia and industry to focus on understanding Modern software engineering concepts & establishing new collaborations in these areas.
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