SlideShare a Scribd company logo
1 of 18
Faculty of Computer Science
Subject: Web Engineering (II)
Lecturer: AbdulBasir Momand
Chapter 2
3
PHP PHP Data Types
• PHP has a total of eight data types and different data
types can do different things.
String
Integer
Float (floating point numbers - also called double)
Boolean
Array
NULL
PHP
PHP Strings:
<?php
$string1 = “I am string !";
$string2 = ‘I am another string';
echo $string1;
echo $string2;
?>
PHP Boolean:
 A Boolean have two possible states or values: TRUE or FALSE.
 Booleans are often used in conditional testing.
PHP ARRAY:
• An array is a variable that can hold more than one value at a time.
• An array is formally defined as an indexed collection of data values. Each index (also known as the key) of an array is
unique and references a corresponding value.
<?php
$color = array("red" , "green" , "blue");
var_dump($color);
?>
. The var_dump function displays structured information about variables/expressions including its type and value.
PHP
PHP NULL:
 The special NULL value is used to represent empty variables in PHP.
 A variable of type NULL is a variable without any data. NULL is the only possible value of type
null.
<?php
$a = NULL;
var_dump($a);
echo "<br>";
$b = "Hello World!";
$b = NULL;
var_dump($b);
?>
PHP
• Length of a String
• <?php
echo strlen("Hello world!"); // outputs 12
?>
• Number of Words in a String
<?php
echo str_word_count("Hello world!"); // outputs 2
?>
• Search For a Specific Text Within a String
<?php
echo strpos("Hello world!", "world"); // outputs 6
?>
Replace Text Within a String
<?php
echo str_replace("world", “mentee", "Hello world!"); // outputs Hello mentee!
?>
PHP 4 Strings
PHP PHP Constants
• PHP constants are name or identifier that can't be
changed during the execution of the script. PHP
constants can be defined by 2 ways:
• Using define() function
• Using const keyword
PHP constant: define()
• Syntax
define(name, value, case-insensitive)
 name: Specifies the name of the constant
 value: Specifies the value of the constant
 case-insensitive: Specifies whether the constant name should be case-insensitive. Default is
false
PHP
<?php
define("MESSAGE","Hello Mentorians");
echo MESSAGE;
?>
• You may write true/false after Mentorians
Example
PHP PHP constant: const keyword
• The const keyword defines constants at compile time.
It is a language construct not a function.
• It is bit faster than define().
• It is always case sensitive.
<?php
const MESSAGE="Hello const by Elegentcoders ";
echo MESSAGE;
?>
PHP
• 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 5 Operators
PHP PHP if-statement
• PHP if statement is executed if condition is true.
<?php
$num=50;
if($num<100)
{
echo "$num is less than 100";
}
?>
PHP PHP If-else Statement
<?php
$num=12;
if($num%2==0){
echo "$num is even number";
}else{
echo "$num is odd number";
}
?>
PHP The if...elseif....else Statement
<?php
$t = 20;
if ($t < "10")
{
echo "Have a good morning!";
}
elseif ($t < "20")
{
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
PHP PHP Switch
<?php
$num=20;
switch($num){
case 10:
echo("number is equals to 10");
break;
case 20:
echo("number is equal to 20");
break;
case 30:
echo("number is equal to 30");
break;
default:
echo("number is not equal to 10, 20 or 30");
}
?>
❤️
Hello, students! I hope you enjoyed the lecture today. I know that sometimes, it can be challenging
to stay focused and engaged during a long class, but I want to remind you of the importance of
your education. You are here because you have a goal in mind, and every class you attend is a
step closer to achieving that goal. Remember, success is not just about talent or ability; it's also
about perseverance and hard work. So, keep pushing yourself to learn, to grow, and to become
the best version of yourself. Don't be afraid to ask questions, seek help when needed, and never
give up on your dreams. The road may be long, but the reward at the end will be worth it. Keep
striving, and I have no doubt that you will achieve greatness.
PHP
Thank You
For Your Patience
PHP 2.pptx

More Related Content

Similar to PHP 2.pptx

Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfAAFREEN SHAIKH
 
Php intro by sami kz
Php intro by sami kzPhp intro by sami kz
Php intro by sami kzsami2244
 
Php(report)
Php(report)Php(report)
Php(report)Yhannah
 
Php web development
Php web developmentPhp web development
Php web developmentRamesh Gupta
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPprabhatjon
 
Php basics
Php basicsPhp basics
Php basicshamfu
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requireTheCreativedev Blog
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfShaimaaMohamedGalal
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Michelangelo van Dam
 
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
 
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
 

Similar to PHP 2.pptx (20)

php basics
php basicsphp basics
php basics
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
Php intro by sami kz
Php intro by sami kzPhp intro by sami kz
Php intro by sami kz
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
01 basics
01 basics01 basics
01 basics
 
php basic
php basicphp basic
php basic
 
Php(report)
Php(report)Php(report)
Php(report)
 
PHP
PHPPHP
PHP
 
Php web development
Php web developmentPhp web development
Php web development
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php basics
Php basicsPhp basics
Php basics
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 
Php operators
Php operatorsPhp operators
Php operators
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
 
Php
PhpPhp
Php
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
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
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
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
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

PHP 2.pptx

  • 1. Faculty of Computer Science Subject: Web Engineering (II) Lecturer: AbdulBasir Momand
  • 3. 3
  • 4. PHP PHP Data Types • PHP has a total of eight data types and different data types can do different things. String Integer Float (floating point numbers - also called double) Boolean Array NULL
  • 5. PHP PHP Strings: <?php $string1 = “I am string !"; $string2 = ‘I am another string'; echo $string1; echo $string2; ?> PHP Boolean:  A Boolean have two possible states or values: TRUE or FALSE.  Booleans are often used in conditional testing. PHP ARRAY: • An array is a variable that can hold more than one value at a time. • An array is formally defined as an indexed collection of data values. Each index (also known as the key) of an array is unique and references a corresponding value. <?php $color = array("red" , "green" , "blue"); var_dump($color); ?> . The var_dump function displays structured information about variables/expressions including its type and value.
  • 6. PHP PHP NULL:  The special NULL value is used to represent empty variables in PHP.  A variable of type NULL is a variable without any data. NULL is the only possible value of type null. <?php $a = NULL; var_dump($a); echo "<br>"; $b = "Hello World!"; $b = NULL; var_dump($b); ?>
  • 7. PHP • Length of a String • <?php echo strlen("Hello world!"); // outputs 12 ?> • Number of Words in a String <?php echo str_word_count("Hello world!"); // outputs 2 ?> • Search For a Specific Text Within a String <?php echo strpos("Hello world!", "world"); // outputs 6 ?> Replace Text Within a String <?php echo str_replace("world", “mentee", "Hello world!"); // outputs Hello mentee! ?> PHP 4 Strings
  • 8. PHP PHP Constants • PHP constants are name or identifier that can't be changed during the execution of the script. PHP constants can be defined by 2 ways: • Using define() function • Using const keyword PHP constant: define() • Syntax define(name, value, case-insensitive)  name: Specifies the name of the constant  value: Specifies the value of the constant  case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false
  • 9. PHP <?php define("MESSAGE","Hello Mentorians"); echo MESSAGE; ?> • You may write true/false after Mentorians Example
  • 10. PHP PHP constant: const keyword • The const keyword defines constants at compile time. It is a language construct not a function. • It is bit faster than define(). • It is always case sensitive. <?php const MESSAGE="Hello const by Elegentcoders "; echo MESSAGE; ?>
  • 11. PHP • 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 5 Operators
  • 12. PHP PHP if-statement • PHP if statement is executed if condition is true. <?php $num=50; if($num<100) { echo "$num is less than 100"; } ?>
  • 13. PHP PHP If-else Statement <?php $num=12; if($num%2==0){ echo "$num is even number"; }else{ echo "$num is odd number"; } ?>
  • 14. PHP The if...elseif....else Statement <?php $t = 20; if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 15. PHP PHP Switch <?php $num=20; switch($num){ case 10: echo("number is equals to 10"); break; case 20: echo("number is equal to 20"); break; case 30: echo("number is equal to 30"); break; default: echo("number is not equal to 10, 20 or 30"); } ?>
  • 16. ❤️ Hello, students! I hope you enjoyed the lecture today. I know that sometimes, it can be challenging to stay focused and engaged during a long class, but I want to remind you of the importance of your education. You are here because you have a goal in mind, and every class you attend is a step closer to achieving that goal. Remember, success is not just about talent or ability; it's also about perseverance and hard work. So, keep pushing yourself to learn, to grow, and to become the best version of yourself. Don't be afraid to ask questions, seek help when needed, and never give up on your dreams. The road may be long, but the reward at the end will be worth it. Keep striving, and I have no doubt that you will achieve greatness.