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

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(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
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
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
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
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
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur 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
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
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
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
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
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
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
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

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.