SlideShare a Scribd company logo
1 of 25
php
• PHP is a server scripting language, and a
powerful tool for making dynamic and
interactive Web pages.
• Example:
What You Should Already Know
• Before you continue you should have a basic
understanding of the following:
• HTML
• CSS
• JavaScript
What is PHP?
• PHP is an acronym for "PHP: Hypertext
Preprocessor"
• PHP is a widely-used, open source scripting
language
• PHP scripts are executed on the server
• PHP is free to download and use
PHP 5 Installation
Set Up PHP on Your Own PC
• However, if your server does not support PHP,
you must:
• install a web server
• install PHP
• install a database, such as MySQL
• The official PHP website (PHP.net) has
installation instructions for
PHP: http://php.net/manual/en/install.php
What is a PHP File?
• PHP files can contain text, HTML, CSS,
JavaScript, and PHP code
• PHP code are executed on the server, and the
result is returned to the browser as plain
HTML
• PHP files have extension ".php"
Basic PHP Syntax
• PHP
• PHP Case Sensitivity
• Php comments
Output Variables
• The PHP echo statement is often used to
output data to the screen.
PHP Variables
• A variable can have a short name (like x and y) or a more
descriptive name (age, carname, total_volume).
Rules for PHP variables:
• A variable starts with the $ sign, followed by the name of
the variable
• A variable name must start with a letter or the underscore
character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters
and underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive ($age and $AGE are two
different variables)
PHP is a Loosely Typed Language
* PHP automatically converts the variable to the
correct data type, depending on its value.
• In other languages such as C, C++, and Java,
the programmer must declare the name and
type of the variable before using it.
PHP Variables Scope
• In PHP, variables can be declared anywhere in
the script.
• The scope of a variable is the part of the script
where the variable can be referenced/used.
• PHP has three different variable scopes:
• local
• global
• static
PHP The static Keyword
• Normally, when a function is
completed/executed, all of its variables are
deleted. However, sometimes we want a local
variable NOT to be deleted. We need it for a
further job.
PHP 5 echo and print Statements
• echo and print are more or less the same.
They are both used to output data to the
screen.
• The differences are small: echo has no return
value while print has a return value of 1 so it
can be used in expressions. echo can take
multiple parameters (although such usage is
rare) while print can take one argument. echo
is marginally faster than print.
PHP String Functions
• Get The Length of a String
• The PHP strlen() function returns the length of
a string.
PHP String Functions
• Count The Number of Words in a String
• The PHP str_word_count() function counts the
number of words in a string:
Reverse a String
• The PHP strrev() function reverses a string:
String Functions
• Search For a Specific Text Within a String
• The PHP strpos() function searches for a
specific text within a string.
String Functions
• Replace Text Within a String
• The PHP str_replace() function replaces some
characters with some other characters in a
string.
• echo str_replace("world", "Dolly", "Hello
world!"); // outputs Hello Dolly!
PHP Operators
• Operators are used to perform operations on variables
and values.
PHP divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Increment/Decrement operators
• Logical operators
• String operators
• Array operators
PHP Arithmetic Operators
PHP Assignment Operators
PHP Comparison Operators
PHP Logical Operators
PHP String Operators
Thanks

More Related Content

What's hot

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 1Mohd Harris Ahmad Jaal
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting languageElmer Concepcion Jr.
 
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...bchrisopher
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in phpSHIVANI SONI
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to pythonbrianjihoonlee
 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryAniruddha Chakrabarti
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)Arjun Shanka
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1Simon Jones
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoadwebuploader
 

What's hot (19)

01 basics
01 basics01 basics
01 basics
 
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 a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
I18n
I18nI18n
I18n
 
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
php_tizag_tutorial
php_tizag_tutorialphp_tizag_tutorial
php_tizag_tutorial
 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural Library
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
 
Php intro
Php introPhp intro
Php intro
 
Introduction About PHP
 Introduction About PHP Introduction About PHP
Introduction About PHP
 
Client side scripting
Client side scriptingClient side scripting
Client side scripting
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Overview of CoffeeScript
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScript
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 

Similar to php basic part one

Similar to php basic part one (20)

Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
web Based Application Devlopment using PHP
web Based Application Devlopment using PHPweb Based Application Devlopment using PHP
web Based Application Devlopment using PHP
 
Php unit i
Php unit iPhp unit i
Php unit i
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Php Basics
Php BasicsPhp Basics
Php Basics
 
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
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Introduction to php contains basic....pptx
Introduction to php contains basic....pptxIntroduction to php contains basic....pptx
Introduction to php contains basic....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).pdf
 
Php1
Php1Php1
Php1
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to 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)
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
INTRODUCTION to php.pptx
INTRODUCTION to php.pptxINTRODUCTION to php.pptx
INTRODUCTION to php.pptx
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variable
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 

php basic part one

  • 1. php • PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. • Example:
  • 2. What You Should Already Know • Before you continue you should have a basic understanding of the following: • HTML • CSS • JavaScript
  • 3. What is PHP? • PHP is an acronym for "PHP: Hypertext Preprocessor" • PHP is a widely-used, open source scripting language • PHP scripts are executed on the server • PHP is free to download and use
  • 5. Set Up PHP on Your Own PC • However, if your server does not support PHP, you must: • install a web server • install PHP • install a database, such as MySQL • The official PHP website (PHP.net) has installation instructions for PHP: http://php.net/manual/en/install.php
  • 6. What is a PHP File? • PHP files can contain text, HTML, CSS, JavaScript, and PHP code • PHP code are executed on the server, and the result is returned to the browser as plain HTML • PHP files have extension ".php"
  • 7. Basic PHP Syntax • PHP • PHP Case Sensitivity • Php comments
  • 8. Output Variables • The PHP echo statement is often used to output data to the screen.
  • 9. PHP Variables • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for PHP variables: • A variable starts with the $ sign, followed by the name of the variable • A variable name must start with a letter or the underscore character • A variable name cannot start with a number • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) • Variable names are case-sensitive ($age and $AGE are two different variables)
  • 10. PHP is a Loosely Typed Language * PHP automatically converts the variable to the correct data type, depending on its value. • In other languages such as C, C++, and Java, the programmer must declare the name and type of the variable before using it.
  • 11. PHP Variables Scope • In PHP, variables can be declared anywhere in the script. • The scope of a variable is the part of the script where the variable can be referenced/used. • PHP has three different variable scopes: • local • global • static
  • 12. PHP The static Keyword • Normally, when a function is completed/executed, all of its variables are deleted. However, sometimes we want a local variable NOT to be deleted. We need it for a further job.
  • 13. PHP 5 echo and print Statements • echo and print are more or less the same. They are both used to output data to the screen. • The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
  • 14. PHP String Functions • Get The Length of a String • The PHP strlen() function returns the length of a string.
  • 15. PHP String Functions • Count The Number of Words in a String • The PHP str_word_count() function counts the number of words in a string:
  • 16. Reverse a String • The PHP strrev() function reverses a string:
  • 17. String Functions • Search For a Specific Text Within a String • The PHP strpos() function searches for a specific text within a string.
  • 18. String Functions • Replace Text Within a String • The PHP str_replace() function replaces some characters with some other characters in a string. • echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
  • 19. PHP Operators • Operators are used to perform operations on variables and values. PHP divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Increment/Decrement operators • Logical operators • String operators • Array operators