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

Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
Arjun Shanka
 

What's hot (20)

PHP
PHPPHP
PHP
 
Php basics
Php basicsPhp basics
Php basics
 
Php string function
Php string function Php string function
Php string function
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php
PhpPhp
Php
 
PHP
PHPPHP
PHP
 
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 - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Php
PhpPhp
Php
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Lesson 2 php data types
Lesson 2   php data typesLesson 2   php data types
Lesson 2 php data types
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php
PhpPhp
Php
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
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
PhpPhp
Php
 

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 tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
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
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php Basics
Php BasicsPhp Basics
Php Basics
 
php41.ppt
php41.pptphp41.ppt
php41.ppt
 

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

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

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