SlideShare a Scribd company logo
1 of 24
PHP Syntax
 A PHP script starts with
<?php
and ends with
?>
<?php
echo "Hello World!";
?>
PHP Variables
 In PHP, a variable starts with the $ sign, followed by the
name of the variable
 <?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
 Rules for PHP variables:
 A variable starts with the $ sign, followed by the name of the
variable
 A variable name must start with a letter or the underscore
character
 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive ($age and $AGE are two
different variables)
PHP echo and print Statements
 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.
PHP echo and print Statements
 <?php
$txt1 = "Learn PHP";
$txt2 = "W3Schools.com";
$x = 5;
$y = 4;
echo "<h2>$txt1</h2>";
echo "Study PHP at $txt2<br>";
print($txt2 );
?>
PHP Data Types
 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
 Object
 NULL
PHP String
 <?php
$x = "Hello world!";
$y = 'Hello world!';
echo $x;
echo "<br>";
echo $y;
?>
PHP Integer
 <?php
$x = 5985;
var_dump($x);
?>
PHP Float
 <?php
$x = 10.365;
var_dump($x);
?>
PHP Boolean
 $x = true;
$y = false;
PHP Array
 An array stores multiple values in one
single variable.
 <?php
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>
PHP Object
 $object =
json_decode(json_encode($array),
FALSE);
 $object = (object) $array_name; //now it
is converted to object and you can
access it.
 echo $object->username;
PHP NULL Value
 Null is a special data type which can have only one
value: NULL.
 A variable of data type NULL is a variable that has no
value assigned to it.
 Tip: If a variable is created without a value, it is
automatically assigned a value of NULL.
 Variables can also be emptied by setting the value to
NULL:
 <?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>
PHP Constants
 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).
 Note: Unlike variables, constants are
automatically global across the entire
script.
PHP Constants
 To create a constant, use the define()
function.
 Syntax :
define(name, value, case-insensitive)
 <?php
define("GREETING", "Welcome to
W3Schools.com!", true);
echo greeting;
?>
PHP 5 Operators
 PHP Operators
 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
PHP Arithmetic Operators
Operator Name Example Result
+ Addition $x + $y Sum of $x and
$y
- Subtraction $x - $y Difference of $x
and $y
* Multiplication $x * $y Product of $x
and $y
/ Division $x / $y Quotient of $x
and $y
% Modulus $x % $y Remainder of $x
divided by $y
** Exponentiation $x ** $y Result of raising
$x to the $y'th
power
(Introduced in
PHP 5.6)
PHP Assignment Operators
Assignment Same as... Description
x = y x = y The left operand gets
set to the value of the
expression on the
right
x += y x = x + y Addition
x -= y x = x - y Subtraction
x *= y x = x * y Multiplication
x /= y x = x / y Division
x %= y x = x % y Modulus
PHP Comparison Operators
Operator Name Example
== Equal $x == $y
=== Identical $x === $y
!= Not equal $x != $y
<> Not equal $x <> $y
!== Not identical $x !== $y
> Greater than $x > $y
< Less than $x < $y
>= Greater than or equal
to
$x >= $y
<= Less than or equal to $x <= $y
PHP Increment / Decrement
Operators
 The PHP increment operators are used
to increment a variable's value.
 The PHP decrement operators are used
to decrement a variable's value.
PHP Increment / Decrement
Operators
 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 Name Description
++$x Pre-increment Increments $x by
one, then returns $x
$x++ Post-increment Returns $x, then
increments $x by one
--$x Pre-decrement Decrements $x by
one, then returns $x
$x-- Post-decrement Returns $x, then
decrements $x by
one
PHP Logical Operators
 The PHP logical operators are used to
combine conditional statements.
Operator Name Example
and And $x and $y
or Or $x or $y
xor Xor $x xor $y
&& And $x && $y
|| Or $x || $y
! Not !$x
PHP String Operators
 PHP has two operators that are
specially designed for strings.
Operator Name Example
. Concatenation $txt1 . $txt2
.= Concatenation
assignment
$txt1 .= $txt2
PHP Array Operators
Operator Name Example
+ Union $x + $y
== Equality $x == $y
=== Identity $x === $y
!= Inequality $x != $y
<> Inequality $x <> $y
!== Non-identity $x !== $y

More Related Content

What's hot

Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...anshkhurana01
 
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database ProgrammingAhmed Swilam
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHPAhmed Swilam
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopessana mateen
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & ArraysHenry Osborne
 
Php 101 by David Menendez
Php 101 by David MenendezPhp 101 by David Menendez
Php 101 by David Menendezdm09f
 
PHP Training Part1
PHP Training Part1PHP Training Part1
PHP Training Part1than sare
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04Hassen Poreya
 

What's hot (20)

Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
Variables in PHP
Variables in PHPVariables in PHP
Variables in PHP
 
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database Programming
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Sorting arrays in PHP
Sorting arrays in PHPSorting arrays in PHP
Sorting arrays in PHP
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
Php 101 by David Menendez
Php 101 by David MenendezPhp 101 by David Menendez
Php 101 by David Menendez
 
php basics
php basicsphp basics
php basics
 
PHP Training Part1
PHP Training Part1PHP Training Part1
PHP Training Part1
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 

Viewers also liked

Prezentacja - Motywacja uczniów do nauki
Prezentacja - Motywacja uczniów do naukiPrezentacja - Motywacja uczniów do nauki
Prezentacja - Motywacja uczniów do naukiAgnieszka Pie
 
Cinemática 1 D
Cinemática 1 DCinemática 1 D
Cinemática 1 DEdwin SB
 
El arte de tejer presentación power point
El arte de tejer   presentación power pointEl arte de tejer   presentación power point
El arte de tejer presentación power pointUniversidad de Murcia
 
güncel referanslar mail eki
güncel referanslar mail ekigüncel referanslar mail eki
güncel referanslar mail ekisamet sahin
 
Tipos de la conducta
Tipos de la conductaTipos de la conducta
Tipos de la conductaGladys López
 
プレゼンテーション2
プレゼンテーション2プレゼンテーション2
プレゼンテーション2hiroaki furusho
 
Republicanism vs Multiculturalism - A critical analysis of the French system ...
Republicanism vs Multiculturalism - A critical analysis of the French system ...Republicanism vs Multiculturalism - A critical analysis of the French system ...
Republicanism vs Multiculturalism - A critical analysis of the French system ...Mélanie Rieder
 
Simpsons Coating Presentation
Simpsons Coating PresentationSimpsons Coating Presentation
Simpsons Coating PresentationVinay Gupta
 

Viewers also liked (15)

FinalCV
FinalCVFinalCV
FinalCV
 
Prezentacja - Motywacja uczniów do nauki
Prezentacja - Motywacja uczniów do naukiPrezentacja - Motywacja uczniów do nauki
Prezentacja - Motywacja uczniów do nauki
 
Cinemática 1 D
Cinemática 1 DCinemática 1 D
Cinemática 1 D
 
El arte de tejer presentación power point
El arte de tejer   presentación power pointEl arte de tejer   presentación power point
El arte de tejer presentación power point
 
güncel referanslar mail eki
güncel referanslar mail ekigüncel referanslar mail eki
güncel referanslar mail eki
 
Tipos de la conducta
Tipos de la conductaTipos de la conducta
Tipos de la conducta
 
z heuwel Cv
z heuwel Cvz heuwel Cv
z heuwel Cv
 
zero conditional
zero conditionalzero conditional
zero conditional
 
プレゼンテーション2
プレゼンテーション2プレゼンテーション2
プレゼンテーション2
 
Trabajo de construccion
Trabajo de construccionTrabajo de construccion
Trabajo de construccion
 
Resume Austine
Resume AustineResume Austine
Resume Austine
 
Republicanism vs Multiculturalism - A critical analysis of the French system ...
Republicanism vs Multiculturalism - A critical analysis of the French system ...Republicanism vs Multiculturalism - A critical analysis of the French system ...
Republicanism vs Multiculturalism - A critical analysis of the French system ...
 
Simpsons Coating Presentation
Simpsons Coating PresentationSimpsons Coating Presentation
Simpsons Coating Presentation
 
Rod Res 1
Rod Res 1Rod Res 1
Rod Res 1
 
No Regrets Project
No Regrets ProjectNo Regrets Project
No Regrets Project
 

Similar to Php introduction

Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics McSoftsis
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboardsDenis Ristic
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpen Gurukul
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfpkaviya
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQLArti Parab Academics
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptxJapneet9
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Javayzebelle
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kianphelios
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaDeepak Rajput
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Gheyath M. Othman
 

Similar to Php introduction (20)

Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
 
PHP-Part1
PHP-Part1PHP-Part1
PHP-Part1
 
Php essentials
Php essentialsPhp essentials
Php essentials
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Php
PhpPhp
Php
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in India
 
Php assignment help
Php assignment helpPhp assignment help
Php assignment help
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Php introduction

  • 1.
  • 2. PHP Syntax  A PHP script starts with <?php and ends with ?> <?php echo "Hello World!"; ?>
  • 3. PHP Variables  In PHP, a variable starts with the $ sign, followed by the name of the variable  <?php $txt = "Hello world!"; $x = 5; $y = 10.5; ?>  Rules for PHP variables:  A variable starts with the $ sign, followed by the name of the variable  A variable name must start with a letter or the underscore character  A variable name cannot start with a number  A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )  Variable names are case-sensitive ($age and $AGE are two different variables)
  • 4. PHP echo and print Statements  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.
  • 5. PHP echo and print Statements  <?php $txt1 = "Learn PHP"; $txt2 = "W3Schools.com"; $x = 5; $y = 4; echo "<h2>$txt1</h2>"; echo "Study PHP at $txt2<br>"; print($txt2 ); ?>
  • 6. PHP Data Types  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  Object  NULL
  • 7. PHP String  <?php $x = "Hello world!"; $y = 'Hello world!'; echo $x; echo "<br>"; echo $y; ?>
  • 8. PHP Integer  <?php $x = 5985; var_dump($x); ?>
  • 9. PHP Float  <?php $x = 10.365; var_dump($x); ?>
  • 10. PHP Boolean  $x = true; $y = false;
  • 11. PHP Array  An array stores multiple values in one single variable.  <?php $cars = array("Volvo","BMW","Toyota"); var_dump($cars); ?>
  • 12. PHP Object  $object = json_decode(json_encode($array), FALSE);  $object = (object) $array_name; //now it is converted to object and you can access it.  echo $object->username;
  • 13. PHP NULL Value  Null is a special data type which can have only one value: NULL.  A variable of data type NULL is a variable that has no value assigned to it.  Tip: If a variable is created without a value, it is automatically assigned a value of NULL.  Variables can also be emptied by setting the value to NULL:  <?php $x = "Hello world!"; $x = null; var_dump($x); ?>
  • 14. PHP Constants  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).  Note: Unlike variables, constants are automatically global across the entire script.
  • 15. PHP Constants  To create a constant, use the define() function.  Syntax : define(name, value, case-insensitive)  <?php define("GREETING", "Welcome to W3Schools.com!", true); echo greeting; ?>
  • 16. PHP 5 Operators  PHP Operators  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
  • 17. PHP Arithmetic Operators Operator Name Example Result + Addition $x + $y Sum of $x and $y - Subtraction $x - $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y / Division $x / $y Quotient of $x and $y % Modulus $x % $y Remainder of $x divided by $y ** Exponentiation $x ** $y Result of raising $x to the $y'th power (Introduced in PHP 5.6)
  • 18. PHP Assignment Operators Assignment Same as... Description x = y x = y The left operand gets set to the value of the expression on the right x += y x = x + y Addition x -= y x = x - y Subtraction x *= y x = x * y Multiplication x /= y x = x / y Division x %= y x = x % y Modulus
  • 19. PHP Comparison Operators Operator Name Example == Equal $x == $y === Identical $x === $y != Not equal $x != $y <> Not equal $x <> $y !== Not identical $x !== $y > Greater than $x > $y < Less than $x < $y >= Greater than or equal to $x >= $y <= Less than or equal to $x <= $y
  • 20. PHP Increment / Decrement Operators  The PHP increment operators are used to increment a variable's value.  The PHP decrement operators are used to decrement a variable's value.
  • 21. PHP Increment / Decrement Operators  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 Name Description ++$x Pre-increment Increments $x by one, then returns $x $x++ Post-increment Returns $x, then increments $x by one --$x Pre-decrement Decrements $x by one, then returns $x $x-- Post-decrement Returns $x, then decrements $x by one
  • 22. PHP Logical Operators  The PHP logical operators are used to combine conditional statements. Operator Name Example and And $x and $y or Or $x or $y xor Xor $x xor $y && And $x && $y || Or $x || $y ! Not !$x
  • 23. PHP String Operators  PHP has two operators that are specially designed for strings. Operator Name Example . Concatenation $txt1 . $txt2 .= Concatenation assignment $txt1 .= $txt2
  • 24. PHP Array Operators Operator Name Example + Union $x + $y == Equality $x == $y === Identity $x === $y != Inequality $x != $y <> Inequality $x <> $y !== Non-identity $x !== $y