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

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

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