SlideShare a Scribd company logo
1 of 21
Download to read offline
Web
Based Application Development
using PHP
Chapter 1
Expressions and Control Statements in PHP
Contents
History of PHP:
• PHP is an "HTML-embedded scripting language" primarily used for
dynamic Web applications.
• PHP takes most of its syntax from C, Java, and Perl.
• It is an open source technology and runs on most operating systems and
with most Web servers.
• PHP was written in the C programming language by Rasmus Lerdorf in
1994 for use in monitoring his online resume and related personal
information.
• For this reason, PHP originally stood for "Personal Home Page"
Versions of PHP
• PHP2:
• The code got another complete makeover, and in April of 1996, combining the
names of past releases, Rasmus introduced PHP/FI(form interface). This second-
version of PHP implementation began to truly evolve PHP from a suite of tools
into a programming language in its own right.
• PHP3:
• PHP 3.0 was the first version that closely resembles PHP as it exists today.
Finding PHP/FI 2.0 still inefficient and lacking features they needed to power an
eCommerce application developers,began yet another complete rewrite of the
underlying parser in 1997. In an effort to improve the language developes
decided to collaborate in the development of a new, independent programming
language. This entirely new language was released under a new name, that
removed the implication of limitedpersonal use that the PHP/FI 2.0 name held.
It was renamed simply 'PHP', with the meaning becoming a recursive acronym -
PHP: Hypertext Preprocessor.
Versions of PHP
• PHP5:
• PHP 5 was released in July 2004 after long development and several pre-
releases. It is mainly driven by its core, the Zend Engine 2.0 with a new
object model and dozens of other new features.PHP's development team
includes dozens of developers, as well as dozens others working on PHP-
related and supporting projects, such as PEAR, PECL, and documentation,
and an underlying network infrastructure of well over one-hundred
individual web servers on six of the seven continents of the world.
• PHP7:
• The PHP development team released the latest version of PHP: PHP 7
claiming it to be twice as fast as its predecessor PHP 5. So, is migrating to
PHP 7
Features and Advantages Of PHP:
• Features Of PHP:
• 1. Open Source
• 2. Develops Dynamic Web sites
• 3. Needs Web server to run
• 4. Supports various datrabases.
• Advantages of PHP:
• 1. Free of Cost
• 2. Open Source
• 3. Platform Independent
• 4. Easy to learn
Syntax of PHP:
• Canonical PHP Tags:The script starts with <?php and ends with ?> . These
tags are
• also called ‘Canonical PHP tags’. Every PHP command ends with a semi-
colon (;).
• Let’s look at the hello world program in PHP:
• <?php
• // Here echo command is used to print
• echo "Hello, world!";
• ?>
1.1 Variables in PHP:
• Variables are used to store data, like string of text, numbers, etc. Variable
values can change over the code. Here're some important things to know
about variables:
• In php variable is declared by following $ symbol.
• In PHP, a variable does not need to be declared before adding a value to
it. PHP automatically converts the variable to the correct data type,
depending on its value. i.e $roll=34; roll variable will get auto declaration
to integer.
• After declaring a variable it can be reused throughout the code.
• The assignment operator (=) used to assign value to a variable.
1.1 Variables in PHP:
• <?php
• $name="nilesh"; //String Variable Declared
• $roll=7; //Int Variable Declared
• $per=NULL; //Blank Variable Declared for later use
• var_dump($name); //display output with data type and value
• var_dump($roll); //display output with data type and value
• var_dump($per); //display output with data type and value
• $per=65.35; //assigning value
• var_dump($per); //display output with data type and value
• echo $name //display value
• print $name //display value
• ?>
1.2 Naming Conventions for PHP Variables
• These are the following rules for naming a PHP variable:
• All variables in PHP start with a $ 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 in PHP can only contain alpha-numeric characters and
underscores (A-z, 0-9,and _).
• A variable name cannot contain spaces.
• The variable name is case sensitive.
2. Constant in PHP
• A constant is a name or an identifier for a fixed value. Constant are like
variables, except that once they are defined, they cannot be changed.
Constants are very useful for storing data that doesn't change while the
script is running.
• Common examples of such data include configuration settings such as
database username and password, website's base URL, company name,
etc.
• Constants are defined using PHP's define() function, which accepts two
arguments: the name of the constant, and its value
• Syntax: define(“variable_name”,value)
• Example: 1) define(“pi”,3.14); 2) define(“dept”,”CSE”);
3.Data Types in PHP:
4. PHP Operators & Expressions
• 4.1 Expressions:
• Expression is nothing but the combination of multiple variables along
with Operator.
• Example: &a+$b+$c; here a b c are variables and + is operator
• $a>$b here a b are variables and > is operator.
4.2 Operators
• Operators are symbols that tell the PHP processor to perform certain
actions.
• For example, the addition (+) symbol is an operator that tells PHP to add
two variables or values,
• while the greater-than (>) symbol is an operator that tells PHP to
compare two values.
4.2.1 Arithmetic Operators
4.2.2 Assignment Operators
Comparison operators
4.2.4 Increament Decrement Operators
Logical operators
String operators
• Thank You

More Related Content

What's hot (20)

PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
PHP .ppt
PHP .pptPHP .ppt
PHP .ppt
 
Presentation php
Presentation phpPresentation php
Presentation php
 
PHP
PHPPHP
PHP
 
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Php functions
Php functionsPhp functions
Php functions
 
.Net Development Services VS | PHP Development Services
.Net Development Services  VS | PHP Development Services.Net Development Services  VS | PHP Development Services
.Net Development Services VS | PHP Development Services
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
 
PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
Advantages of Choosing PHP Web Development
Advantages of Choosing PHP Web DevelopmentAdvantages of Choosing PHP Web Development
Advantages of Choosing PHP Web Development
 
Php1
Php1Php1
Php1
 
What is html
What is htmlWhat is html
What is html
 
Decoupled drupal
Decoupled drupal Decoupled drupal
Decoupled drupal
 
Apache Thrift : One Stop Solution for Cross Language Communication
Apache Thrift : One Stop Solution for Cross Language CommunicationApache Thrift : One Stop Solution for Cross Language Communication
Apache Thrift : One Stop Solution for Cross Language Communication
 
Php&amp;yii2
Php&amp;yii2Php&amp;yii2
Php&amp;yii2
 
Drupal 8 customized checkout system
Drupal 8 customized checkout systemDrupal 8 customized checkout system
Drupal 8 customized checkout system
 
Sending emails through PHP
Sending emails through PHPSending emails through PHP
Sending emails through PHP
 
Php presentation
Php presentationPhp presentation
Php presentation
 

Similar to PHP Web App Development Using PHP - Expressions and Control Statements

Similar to PHP Web App Development Using PHP - Expressions and Control Statements (20)

php basic part one
php basic part onephp basic part one
php basic part one
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variable
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Php
PhpPhp
Php
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Introduction to php
Introduction  to  phpIntroduction  to  php
Introduction to php
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
Php notes
Php notesPhp notes
Php notes
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php unit i
Php unit i Php unit i
Php unit i
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
 
Php
PhpPhp
Php
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 

PHP Web App Development Using PHP - Expressions and Control Statements

  • 1. Web Based Application Development using PHP Chapter 1 Expressions and Control Statements in PHP
  • 3. History of PHP: • PHP is an "HTML-embedded scripting language" primarily used for dynamic Web applications. • PHP takes most of its syntax from C, Java, and Perl. • It is an open source technology and runs on most operating systems and with most Web servers. • PHP was written in the C programming language by Rasmus Lerdorf in 1994 for use in monitoring his online resume and related personal information. • For this reason, PHP originally stood for "Personal Home Page"
  • 4. Versions of PHP • PHP2: • The code got another complete makeover, and in April of 1996, combining the names of past releases, Rasmus introduced PHP/FI(form interface). This second- version of PHP implementation began to truly evolve PHP from a suite of tools into a programming language in its own right. • PHP3: • PHP 3.0 was the first version that closely resembles PHP as it exists today. Finding PHP/FI 2.0 still inefficient and lacking features they needed to power an eCommerce application developers,began yet another complete rewrite of the underlying parser in 1997. In an effort to improve the language developes decided to collaborate in the development of a new, independent programming language. This entirely new language was released under a new name, that removed the implication of limitedpersonal use that the PHP/FI 2.0 name held. It was renamed simply 'PHP', with the meaning becoming a recursive acronym - PHP: Hypertext Preprocessor.
  • 5. Versions of PHP • PHP5: • PHP 5 was released in July 2004 after long development and several pre- releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model and dozens of other new features.PHP's development team includes dozens of developers, as well as dozens others working on PHP- related and supporting projects, such as PEAR, PECL, and documentation, and an underlying network infrastructure of well over one-hundred individual web servers on six of the seven continents of the world. • PHP7: • The PHP development team released the latest version of PHP: PHP 7 claiming it to be twice as fast as its predecessor PHP 5. So, is migrating to PHP 7
  • 6. Features and Advantages Of PHP: • Features Of PHP: • 1. Open Source • 2. Develops Dynamic Web sites • 3. Needs Web server to run • 4. Supports various datrabases. • Advantages of PHP: • 1. Free of Cost • 2. Open Source • 3. Platform Independent • 4. Easy to learn
  • 7. Syntax of PHP: • Canonical PHP Tags:The script starts with <?php and ends with ?> . These tags are • also called ‘Canonical PHP tags’. Every PHP command ends with a semi- colon (;). • Let’s look at the hello world program in PHP: • <?php • // Here echo command is used to print • echo "Hello, world!"; • ?>
  • 8. 1.1 Variables in PHP: • Variables are used to store data, like string of text, numbers, etc. Variable values can change over the code. Here're some important things to know about variables: • In php variable is declared by following $ symbol. • In PHP, a variable does not need to be declared before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value. i.e $roll=34; roll variable will get auto declaration to integer. • After declaring a variable it can be reused throughout the code. • The assignment operator (=) used to assign value to a variable.
  • 9. 1.1 Variables in PHP: • <?php • $name="nilesh"; //String Variable Declared • $roll=7; //Int Variable Declared • $per=NULL; //Blank Variable Declared for later use • var_dump($name); //display output with data type and value • var_dump($roll); //display output with data type and value • var_dump($per); //display output with data type and value • $per=65.35; //assigning value • var_dump($per); //display output with data type and value • echo $name //display value • print $name //display value • ?>
  • 10. 1.2 Naming Conventions for PHP Variables • These are the following rules for naming a PHP variable: • All variables in PHP start with a $ 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 in PHP can only contain alpha-numeric characters and underscores (A-z, 0-9,and _). • A variable name cannot contain spaces. • The variable name is case sensitive.
  • 11. 2. Constant in PHP • A constant is a name or an identifier for a fixed value. Constant are like variables, except that once they are defined, they cannot be changed. Constants are very useful for storing data that doesn't change while the script is running. • Common examples of such data include configuration settings such as database username and password, website's base URL, company name, etc. • Constants are defined using PHP's define() function, which accepts two arguments: the name of the constant, and its value • Syntax: define(“variable_name”,value) • Example: 1) define(“pi”,3.14); 2) define(“dept”,”CSE”);
  • 13. 4. PHP Operators & Expressions • 4.1 Expressions: • Expression is nothing but the combination of multiple variables along with Operator. • Example: &a+$b+$c; here a b c are variables and + is operator • $a>$b here a b are variables and > is operator.
  • 14. 4.2 Operators • Operators are symbols that tell the PHP processor to perform certain actions. • For example, the addition (+) symbol is an operator that tells PHP to add two variables or values, • while the greater-than (>) symbol is an operator that tells PHP to compare two values.