SlideShare a Scribd company logo
PHP Workshop 1
PHP: The Basics
PHP Workshop 2
What is it?
• PHP is a scripting language commonly
used on web servers.
– Stands for “PHP: Hypertext Preprocessor”
– Open source
– Embedded code
– Comparable with ASP
– Multiple operating systems/web servers
PHP Workshop 3
The PHP Resource
www.php.net
PHP Workshop 4
What can it do?
• Dynamic generation of web-page content
• Database interaction
• Processing of user supplied data
• Email
• File handling
• Text processing
• Network interaction
• And more…
PHP Workshop 5
Fundamentals
• PHP is embedded within xhtml pages
within the tags: <?php … ?>
• The short version of these tags can also
be used: <? … ?>
• Each line of PHP is terminated, like
MySQL, with a semi-colon.
PHP Workshop 6
Hello World!
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo ‘<p>Hello World!</p>’; ?>
</body>
</html>
PHP Workshop 7
Preparing to code with PHP
PHP Workshop 8
Literals..
• All strings must be enclosed in single of
double quotes: ‘Hello’ or “Hello”.
• Numbers are not in enclosed in quotes: 1
or 45 or 34.564
• Booleans (true/flase) can be written
directly as true or false.
PHP Workshop 9
Comments
// This is a comment
# This is also a comment
/* This is a comment
that is spread over
multiple lines */
• Do not nest multi-line comments
• // recommended over #
PHP Workshop 10
Comments
<?php
// this is a comment
echo ‘Hello World!’;
/* another
multi-line comment */
?>
PHP Workshop 11
Displaying Data
• There are two language constructs
available to display data: print() and
echo().
• They can be used with or without
brackets.
• Note that the data ‘displayed’ by PHP is
actually parsed by your browser as HTML.
View source to see actual output.
PHP Workshop 12
Displaying data
<?php
echo ‘Hello World!<br />’;
echo(‘Hello World!<br />’);
print ‘Hello World!<br />’;
print(‘Hello World!<br />’);
?>
PHP Workshop 13
Escaping Characters
• Some characters are considered ‘special’
• Escape these with a backslash 
• Special characters will be flagged when
they arise, for example a double or single
quote belong in this group…
PHP Workshop 14
Escaping Characters
<?php
// Claire O’Reilly said “Hello”.
echo ‘Claire O’Reilly ’;
echo “said ”Hello”.”;
?>
PHP Workshop 15
Variables: What are they?
• When we work in PHP, we often need a
labelled place to store a value (be it a
string, number, whatever) so we can use it
in multiple places in our script.
• These labelled ‘places’ are called
VARIABLES
PHP Workshop 16
Variables: Naming
• $ followed by variable name
• Case sensitive
– $variable differs from $Variable
– Stick to lower-case to be sure!
• Name must started with a letter or an
underscore
– Followed by any number of letters, numbers
and underscores
PHP Workshop 17
Variables: example
<?php
$name = ‘Phil’;
$age = 23;
echo $name;
echo ’ is ‘;
echo $age;
// Phil is 23
?>
PHP Workshop 18
Constants
• Constants (unchangeable variables)
can also be defined.
• Each constant is given a name (note
no preceding dollar is applied here).
• By convention, constant names are
usually in UPPERCASE.
PHP Workshop 19
Constants
<?php
define(‘NAME’,‘Phil’);
define(‘AGE’,23);
echo NAME;
echo ’ is ‘;
echo AGE;
// Phil is 23
?>
PHP Workshop 20
“ or ‘ ?
• There is a difference between strings
written in single and double quotes.
• In a double-quoted string any variable
names are expanded to their values.
• In a single-quoted string, no variable
expansion takes place.
PHP Workshop 21
“ or ‘ ?
<?php
$name = ‘Phil’;
$age = 23;
echo “$name is $age”;
// Phil is 23
?>
PHP Workshop 22
“ or ‘ ?
<?php
$name = ‘Phil’;
$age = 23;
echo ‘$name is $age’;
// $name is $age
?>
PHP Workshop 23
Review
• We’ve started PHP..
– Escaping XHTML
– Comments
– Basic Syntax
– Variables
– Constants

More Related Content

What's hot

Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
SHIVANI SONI
 
php basic part one
php basic part onephp basic part one
php basic part one
jeweltutin
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
MLG College of Learning, Inc
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
Mohamed Loey
 
Php tutorial
Php  tutorialPhp  tutorial
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Php & mysqli in urdu
Php & mysqli in urduPhp & mysqli in urdu
Php & mysqli in urdu
Abdul Wali
 
Php basics
Php basicsPhp basics
Php basics
Jamshid Hashimi
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
Eric Johnson
 
php basics
php basicsphp basics
php basics
NIRMAL FELIX
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
Sacheen Dhanjie
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
Vijay Kumar Verma
 
[WebCamp2014] Towards functional web
[WebCamp2014] Towards functional web[WebCamp2014] Towards functional web
[WebCamp2014] Towards functional web
Blaž Repas
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
Dhani Ahmad
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Anjan Banda
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
Geshan Manandhar
 

What's hot (20)

Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
php basic part one
php basic part onephp basic part one
php basic part one
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
Php tutorial
Php  tutorialPhp  tutorial
Php tutorial
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Php & mysqli in urdu
Php & mysqli in urduPhp & mysqli in urdu
Php & mysqli in urdu
 
Php basics
Php basicsPhp basics
Php basics
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
php basics
php basicsphp basics
php basics
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
 
[WebCamp2014] Towards functional web
[WebCamp2014] Towards functional web[WebCamp2014] Towards functional web
[WebCamp2014] Towards functional web
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 

Viewers also liked

Apache - Quick reference guide
Apache - Quick reference guideApache - Quick reference guide
Apache - Quick reference guide
Joseph's WebSphere Library
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
Vineet Kumar Saini
 
Best Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle DatabaseBest Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle Database
Christopher Jones
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
Mayflower GmbH
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical Questions
Pankaj Jha
 
25 php interview questions – codementor
25 php interview questions – codementor25 php interview questions – codementor
25 php interview questions – codementor
Arc & Codementor
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
webhostingguy
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Php mysql ppt
Php mysql pptPhp mysql ppt

Viewers also liked (12)

Apache - Quick reference guide
Apache - Quick reference guideApache - Quick reference guide
Apache - Quick reference guide
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
 
Best Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle DatabaseBest Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle Database
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical Questions
 
25 php interview questions – codementor
25 php interview questions – codementor25 php interview questions – codementor
25 php interview questions – codementor
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 

Similar to php basic

01-basics.ppt
01-basics.ppt01-basics.ppt
01-basics.ppt
SmartKutti1
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
Robby Firmansyah
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Basics PHP
Basics PHPBasics PHP
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Sush Singhaniya
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
DanWooster1
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
 
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
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
HambaAbebe2
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
HambardeAtharva
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
AhmedAElHalimAhmed
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
MacSila
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
jeeva indra
 
basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
Arjun Shanka
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
rasool noorpour
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
Nisa Soomro
 
php basics
php basicsphp basics
php basics
Anmol Paul
 
Intro to php
Intro to phpIntro to php
Intro to php
Ahmed Farag
 
Introduction to php contains basic....pptx
Introduction to php contains basic....pptxIntroduction to php contains basic....pptx
Introduction to php contains basic....pptx
RanjithaGowda63
 

Similar to php basic (20)

01-basics.ppt
01-basics.ppt01-basics.ppt
01-basics.ppt
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
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 Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
php basics
php basicsphp basics
php basics
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Introduction to php contains basic....pptx
Introduction to php contains basic....pptxIntroduction to php contains basic....pptx
Introduction to php contains basic....pptx
 

Recently uploaded

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 

Recently uploaded (20)

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 

php basic

  • 1. PHP Workshop 1 PHP: The Basics
  • 2. PHP Workshop 2 What is it? • PHP is a scripting language commonly used on web servers. – Stands for “PHP: Hypertext Preprocessor” – Open source – Embedded code – Comparable with ASP – Multiple operating systems/web servers
  • 3. PHP Workshop 3 The PHP Resource www.php.net
  • 4. PHP Workshop 4 What can it do? • Dynamic generation of web-page content • Database interaction • Processing of user supplied data • Email • File handling • Text processing • Network interaction • And more…
  • 5. PHP Workshop 5 Fundamentals • PHP is embedded within xhtml pages within the tags: <?php … ?> • The short version of these tags can also be used: <? … ?> • Each line of PHP is terminated, like MySQL, with a semi-colon.
  • 6. PHP Workshop 6 Hello World! <html> <head> <title>PHP Test</title> </head> <body> <?php echo ‘<p>Hello World!</p>’; ?> </body> </html>
  • 7. PHP Workshop 7 Preparing to code with PHP
  • 8. PHP Workshop 8 Literals.. • All strings must be enclosed in single of double quotes: ‘Hello’ or “Hello”. • Numbers are not in enclosed in quotes: 1 or 45 or 34.564 • Booleans (true/flase) can be written directly as true or false.
  • 9. PHP Workshop 9 Comments // This is a comment # This is also a comment /* This is a comment that is spread over multiple lines */ • Do not nest multi-line comments • // recommended over #
  • 10. PHP Workshop 10 Comments <?php // this is a comment echo ‘Hello World!’; /* another multi-line comment */ ?>
  • 11. PHP Workshop 11 Displaying Data • There are two language constructs available to display data: print() and echo(). • They can be used with or without brackets. • Note that the data ‘displayed’ by PHP is actually parsed by your browser as HTML. View source to see actual output.
  • 12. PHP Workshop 12 Displaying data <?php echo ‘Hello World!<br />’; echo(‘Hello World!<br />’); print ‘Hello World!<br />’; print(‘Hello World!<br />’); ?>
  • 13. PHP Workshop 13 Escaping Characters • Some characters are considered ‘special’ • Escape these with a backslash • Special characters will be flagged when they arise, for example a double or single quote belong in this group…
  • 14. PHP Workshop 14 Escaping Characters <?php // Claire O’Reilly said “Hello”. echo ‘Claire O’Reilly ’; echo “said ”Hello”.”; ?>
  • 15. PHP Workshop 15 Variables: What are they? • When we work in PHP, we often need a labelled place to store a value (be it a string, number, whatever) so we can use it in multiple places in our script. • These labelled ‘places’ are called VARIABLES
  • 16. PHP Workshop 16 Variables: Naming • $ followed by variable name • Case sensitive – $variable differs from $Variable – Stick to lower-case to be sure! • Name must started with a letter or an underscore – Followed by any number of letters, numbers and underscores
  • 17. PHP Workshop 17 Variables: example <?php $name = ‘Phil’; $age = 23; echo $name; echo ’ is ‘; echo $age; // Phil is 23 ?>
  • 18. PHP Workshop 18 Constants • Constants (unchangeable variables) can also be defined. • Each constant is given a name (note no preceding dollar is applied here). • By convention, constant names are usually in UPPERCASE.
  • 20. PHP Workshop 20 “ or ‘ ? • There is a difference between strings written in single and double quotes. • In a double-quoted string any variable names are expanded to their values. • In a single-quoted string, no variable expansion takes place.
  • 21. PHP Workshop 21 “ or ‘ ? <?php $name = ‘Phil’; $age = 23; echo “$name is $age”; // Phil is 23 ?>
  • 22. PHP Workshop 22 “ or ‘ ? <?php $name = ‘Phil’; $age = 23; echo ‘$name is $age’; // $name is $age ?>
  • 23. PHP Workshop 23 Review • We’ve started PHP.. – Escaping XHTML – Comments – Basic Syntax – Variables – Constants

Editor's Notes

  1. Using your favoured text editor (e.g. Notepad) create the file on the slide… Save it in your web space as hello.php and navigate to the file via your web browser You should see Hello World! On the page… If that has worked replace all with phpinfo(); and run again… You should now see a page with lots of information about the PHP installation – this will become useful later! NOT XHTML (NO DOCTYPE SETTING ETC) TO SAVE SPACE ON PAGE…
  2. Demo the fact that the variable can be changed.. $name = ‘Phil’; $age = 23; $name = ‘Ed’; echo $name; echo ’ is ‘; echo $age; // Ed is 23
  3. A constant is an identifier for a single value… Cannot be changed during execution (or undefined) Same naming convention as a standard variable (just no $) Are global (can be accessed anywhere – within functions, etc.) There are many predefined constants (see www.php.net for the long list!) Core constants Set in the PHP core… Mostly to do with error tracking and also core items like version, install directories, etc. Standard constants Loads more! Extension constants These are set by extensions if they are loaded See individual extension descriptions for details
  4. Demo the fact that the variable can be changed.. $name = ‘Phil’; $age = 23; $name = ‘Ed’; echo $name; echo ’ is ‘; echo $age; // Ed is 23
  5. Demo the fact that the variable can be changed.. $name = ‘Phil’; $age = 23; $name = ‘Ed’; echo $name; echo ’ is ‘; echo $age; // Ed is 23