SlideShare a Scribd company logo
1 of 23
PHP ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Continued... ,[object Object],[object Object],[object Object]
Where To Start ,[object Object],[object Object],[object Object],[object Object]
Syntax PHP code is executed on the server, and the plain HTML result is sent to the browser. A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document. On servers with shorthand support enabled you can start a scripting block with <? and end with ?>. For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form. <?php ?>  A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
Continued.. Below, we have an example of a simple PHP script which sends the text &quot;Hello World&quot; to the browser: <html> <body> <?php echo &quot;Hello World&quot;; ?> </body> </html>
Continued... Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text &quot;Hello World&quot;. Comments in PHP In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.
Variables in PHP ,[object Object],Variables are used for storing a values, like text strings, numbers or arrays. When a variable is declared, it can be used over and over again in your script. All variables in PHP start with a  $ sign symbol . The correct way of declaring a variable in PHP: $var_name = value;
Naming Rules for Variables ,[object Object],A variable name must start with a letter or an underscore &quot;_&quot; A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ) A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)
String Variables in PHP String variables are used for values that contains characters. PHP script assigns the text &quot;Hello World&quot; to a string variable called $txt: <?php $txt=&quot;Hello World&quot;; echo $txt; ?>
Continued... The Concatenation Operator There is only one string operator in PHP. The concatenation operator (.)  is used to put two string values together. The strlen() function The strlen() function is used to return the length of a string. <?php echo strlen(&quot;Hello world!&quot;); ?>  ,[object Object],[object Object]
Continued... The strpos() function The strpos() function is used to search for character within a string. If a match is found, this function will return the position of the first match. If no match is found, it will return FALSE . <?php echo strpos(&quot;Hello world!&quot;,&quot;world&quot;); ?>  Output :  6 The position of the string &quot;world&quot; in our string is position 6. The reason that it is 6 (and not 7), is that the first position in the string is 0, and not 1.
PHP Operators ,[object Object],[object Object],[object Object],[object Object]
Conditional Statements In PHP we have the following conditional statements: if statement  - use this statement to execute some code only if a specified condition is true if...else statement  - use this statement to execute some code if a condition is true and another code if the condition is false if...elseif....else statement  - use this statement to select one of several blocks of code to be executed switch statement  - use this statement to select one of many blocks of code to be executed
PHP Arrays An array stores multiple values in one single variable. In PHP, there are three kind of arrays: Numeric array  - An array with a numeric index Associative array  - An array where each ID key is associated with a value Multidimensional array  - An array containing one or more arrays
PHP Looping ,[object Object],Loops execute a block of code a specified number of times, or while a specified condition is true. In PHP, we have the following looping statements: while  - loops through a block of code while a specified condition is true do...while  - loops through a block of code once, and then repeats the loop as long  as a specified condition is true for  - loops through a block of code a specified number of times foreach  - loops through a block of code for each element in an array
PHP Functions In PHP, there are more than 700 built-in functions. A function will be executed by a call to the function. You may call a function from anywhere within a page. Syntax function functionName() { code to be executed; }
Forms and User Input ,[object Object],The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. PHP Form Handling The most important thing to notice when dealing with HTML forms and PHP is that any  form element in an HTML page will automatically be available to your PHP scripts.
Continued... Example The example below contains an HTML form with two input fields and a submit button: <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html>
PHP $_GET Function The built-in $_GET function is used to collect values in a form with  method=&quot;get&quot;. Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send (max. 100 characters). Example <form action=&quot;welcome.php&quot; method=&quot;get&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form>
Continued... ,[object Object],[object Object],[object Object]
PHP $_POST Function The built-in $_POST function is used to collect values in a form with method=&quot;post&quot;. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. Example <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form>
Continued... When to use method=&quot;post&quot;? Information sent from a form with the POST method is invisible to others  and has no limits on the amount of information to send. The PHP $_REQUEST Function The PHP built-in $_REQUEST function contains the contents of both $_GET, $_POST, and $_COOKIE. The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. x

More Related Content

What's hot

What's hot (20)

Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
CSS
CSSCSS
CSS
 
Overview of PHP and MYSQL
Overview of PHP and MYSQLOverview of PHP and MYSQL
Overview of PHP and MYSQL
 
HTML5 & CSS3
HTML5 & CSS3 HTML5 & CSS3
HTML5 & CSS3
 
Css
CssCss
Css
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Html
HtmlHtml
Html
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation Technique
 
html-css
html-csshtml-css
html-css
 
HTML & CSS Masterclass
HTML & CSS MasterclassHTML & CSS Masterclass
HTML & CSS Masterclass
 

Viewers also liked

Viewers also liked (6)

PHP Basic & Arrays
PHP Basic & ArraysPHP Basic & Arrays
PHP Basic & Arrays
 
Array in php
Array in phpArray in php
Array in php
 
03 Php Array String Functions
03 Php Array String Functions03 Php Array String Functions
03 Php Array String Functions
 
Php array
Php arrayPhp array
Php array
 
Php array
Php arrayPhp array
Php array
 
Php string function
Php string function Php string function
Php string function
 

Similar to Php (20)

Php
PhpPhp
Php
 
PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
 
PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
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
 
Web development
Web developmentWeb development
Web development
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Php1
Php1Php1
Php1
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php essentials
Php essentialsPhp essentials
Php essentials
 
Introduction to PHP.ppt
Introduction to PHP.pptIntroduction to PHP.ppt
Introduction to PHP.ppt
 
Php
PhpPhp
Php
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 
Php
PhpPhp
Php
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 

More from Ajaigururaj R (18)

Chennai Guide
Chennai GuideChennai Guide
Chennai Guide
 
Chennai Guide
Chennai GuideChennai Guide
Chennai Guide
 
Chennai Guide
Chennai GuideChennai Guide
Chennai Guide
 
Year 2070
Year 2070Year 2070
Year 2070
 
CCNA presentation.
CCNA presentation.CCNA presentation.
CCNA presentation.
 
Survey
SurveySurvey
Survey
 
Quiz on heart
Quiz on heartQuiz on heart
Quiz on heart
 
Quiz in cancer
Quiz in cancerQuiz in cancer
Quiz in cancer
 
Quiz in cancer
Quiz in cancerQuiz in cancer
Quiz in cancer
 
Quiz
QuizQuiz
Quiz
 
Diabetes
DiabetesDiabetes
Diabetes
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Wordpress
Wordpress Wordpress
Wordpress
 
Sample app
Sample appSample app
Sample app
 
Opensource and openlearning
Opensource and openlearningOpensource and openlearning
Opensource and openlearning
 
work Chart
work Chart work Chart
work Chart
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Web2 ppt
Web2 pptWeb2 ppt
Web2 ppt
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
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
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Php

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. Syntax PHP code is executed on the server, and the plain HTML result is sent to the browser. A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document. On servers with shorthand support enabled you can start a scripting block with <? and end with ?>. For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form. <?php ?> A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
  • 6. Continued.. Below, we have an example of a simple PHP script which sends the text &quot;Hello World&quot; to the browser: <html> <body> <?php echo &quot;Hello World&quot;; ?> </body> </html>
  • 7. Continued... Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text &quot;Hello World&quot;. Comments in PHP In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.
  • 8.
  • 9.
  • 10. String Variables in PHP String variables are used for values that contains characters. PHP script assigns the text &quot;Hello World&quot; to a string variable called $txt: <?php $txt=&quot;Hello World&quot;; echo $txt; ?>
  • 11.
  • 12. Continued... The strpos() function The strpos() function is used to search for character within a string. If a match is found, this function will return the position of the first match. If no match is found, it will return FALSE . <?php echo strpos(&quot;Hello world!&quot;,&quot;world&quot;); ?> Output : 6 The position of the string &quot;world&quot; in our string is position 6. The reason that it is 6 (and not 7), is that the first position in the string is 0, and not 1.
  • 13.
  • 14. Conditional Statements In PHP we have the following conditional statements: if statement - use this statement to execute some code only if a specified condition is true if...else statement - use this statement to execute some code if a condition is true and another code if the condition is false if...elseif....else statement - use this statement to select one of several blocks of code to be executed switch statement - use this statement to select one of many blocks of code to be executed
  • 15. PHP Arrays An array stores multiple values in one single variable. In PHP, there are three kind of arrays: Numeric array - An array with a numeric index Associative array - An array where each ID key is associated with a value Multidimensional array - An array containing one or more arrays
  • 16.
  • 17. PHP Functions In PHP, there are more than 700 built-in functions. A function will be executed by a call to the function. You may call a function from anywhere within a page. Syntax function functionName() { code to be executed; }
  • 18.
  • 19. Continued... Example The example below contains an HTML form with two input fields and a submit button: <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html>
  • 20. PHP $_GET Function The built-in $_GET function is used to collect values in a form with method=&quot;get&quot;. Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send (max. 100 characters). Example <form action=&quot;welcome.php&quot; method=&quot;get&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form>
  • 21.
  • 22. PHP $_POST Function The built-in $_POST function is used to collect values in a form with method=&quot;post&quot;. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. Example <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form>
  • 23. Continued... When to use method=&quot;post&quot;? Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. The PHP $_REQUEST Function The PHP built-in $_REQUEST function contains the contents of both $_GET, $_POST, and $_COOKIE. The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. x