• Save
Coding In Php
Upcoming SlideShare
Loading in...5
×
 

Coding In Php

on

  • 1,811 views

 

Statistics

Views

Total Views
1,811
Views on SlideShare
1,804
Embed Views
7

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 7

http://www.linkedin.com 6
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Coding In Php Coding In Php Presentation Transcript

  • PHP – Coding in PHP Harit Kothari [email_address]
  • Agenda
    • PHP HTML Embedding Tags and Syntax
    • Simple PHP Script Example
    • PHP and HTTP Environment Variables
  • PHP HTML Embedding Tags and Syntax
    • HTML is written as <tag>content<tag>
    • Similarly, PHP Tags can be written as: <?php method; ? > e.g. <?php echo ”Hello World!”; ?>
    • So how does it makes sense? - Use different methods to generate contents dynamically - Call PHP functions and get results at runtime
  • Some other ways to achieve the same
    • SGML Style (we have already seen!) <?php echo ”Hello World!”; ?>
    • ASP / JSP Style <% echo “Hello World!”; %> OR (Shortcut) <p><?=”Hello World!”; ?>
    • (Java)Script Style <script language = “php”> echo “Hello World!”; </script>
  • Simple PHP Script Example
    • A sample program that illustrates different ways to code PHP! <html> <head><title><? Echo “This is a sample PHP page!”; ?></title></head> <body> <h2>A math example</h2> <p>10 + 11 = <%= 10+11 %> <br/>and 8 + 9 = <% echo(8+9); %> </body> </html>
  • PHP and HTTP Environment Variables
    • HTTP as a protocol is different, in PHP it has rich set of Global / environment variables.
    • They are accessible globally!
    • $HTTP_GET_VARS or $_GET
    • $HTTP_POST_VARS or $_POST
    • $HTTP_COOKIE_VARS or $_COOKIE
    • $HTTP_SERVER_VARS or $_SERVER
    • $HTTP_ENV_VARS or $_ENV
    • $HTTP_POST_FILES
  • PHP and HTTP Environment Variables - 1
    • $HTTP_GET_VARS & $HTTP_POST_VARS
      • Mostly used in GET and POST requests respectively.
      • Contains request information / data.
      • Useful in form processing.
  • PHP and HTTP Environment Variables - 2
    • $HTTP_COOKIE_VARS
      • Cookie is a very small, temporary text file
      • A way of session management
      • Stored and retrieved user specific information on client
  • PHP and HTTP Environment Variables - 3
    • $HTTP_SERVER_VARS
      • Various information about server
      • Examples: SERVER_SOFTWARE “wamp” SERVER_NAME “www.sachinism.com” SERVER_PROTOCOL “HTTP/1.1” SERVER_PORT “80” REQUEST_METHOD “POST” QUERY_STRING “nm=hussu+age=32” REMOTE_HOST “hostname_machine” REMOTE_ADDR “192.168.10.1” AUTH_TYPE “basic” CONTENT_TYPE “x-url-encoded”
  • PHP and HTTP Environment Variables - 4
    • $HTTP_ENV_VARS
      • Related to accessing machine and OS specific environment variables
    • $HTTP_POST_FILES
      • Related to file upload
  • Summary
    • PHP can be written in either of 3 ways, SGML, Script or ASP / JSP styles.
    • PHP environment variables like $_GET, $_POST, $_COOKIE, $_SERVER provides access to data stored in different ways like sent as request, stored as cookies, or some data about server.
  • Whats next?
    • Learning language in dept...
      • Variables, Constants and Data Types, and Operators
      • Decision Making, Flow Control and Loops