php tutorial - PHP - what is php - PHP Tutorial - php programming - learn php - php code - php script



What is PHP - How PHP works

php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - php-interpreter
  • PHP stands for "PHP Hypertext Preprocessor"
  • Server-side scripting language
  • Used to make web pages dynamic:
  • provide different content depending on context
  • interface with other services: database, e-mail, etc.
  • authenticate users
  • process form information
  • PHP code can be embedded in XHTML code
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - what is php

    What is web server

  • Usually when you type a URL in your browser:
  • Your computer looks up the server's IP address using DNS
  • Your browser connects to that IP address and requests the given file
  • The web server software (e.g. Apache) grabs that file from the
  • server's local file system
  • The server sends back its contents to you
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server

    http://www.facebook.com/home.php

  • Some URLs actually specify programs that the web server should run, and then send their output back to you as the result:
    • The above URL tells the server facebook.com to run the programhome.php and send back its output
  • Server-Side web programming

  • Server-side pages are programs written using one of many web programming languages/frameworks examples: PHP, Java/JSP, Ruby on Rails, ASP.NET, Python, Perl
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - server side programming
  • Also called server side scripting:
    • Dynamically edit, change or add any content to a Web page
    • Respond to user queries or data submitted from HTML forms
    • Access any data or databases and return the results to a browser
    • Customize a Web page to make it more useful for individual users
    • Provide security since your server code cannot be viewed from a browser
  • Web server:
    • contains software that allows it to run server side programs
    • sends back their output as responses to web requests
  • Each language/framework has its pros and cons
    • we use PHP

    Lifecycle of a PHP web request

    php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php life cycle

    Why PHP?

  • Free and open source
  • Compatible
    • as of November 2006, there were more than 19 million websites (domain names) using PHP.
  • Simple
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php hello world

    Viewing PHP output

    php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php hello world

    PHP syntax template

    php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax
  • Contents of a .php file between <?php and ?> are executed as PHP code
  • All other contents are output as pure HTML
  • We can switch back and forth between HTML and PHP "modes"
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax

    Single Page in PHP

  • Make the form submit to the same page.
  • Why? It keeps everything in one place, and means you only write the form once.
  •   <form action="<?php echo $_SERVER['PHP_SELF']; ?>"
          method="post"
          …
    click below button to copy the code. php tutorial - team

    php validation

    if (form has been submitted) {
        // validate form
    }
    if (valid submission) {
        // action data
    } else {
        // (re)display form
    }
    click below button to copy the code. php tutorial - team

  • further validating the pages
  •  if (form has been submitted) {
        // validate form
    }
        …can be implemented as…
    if (isset($_POST[‘submit’])) {
        // validate form
    }
    click below button to copy the code. php tutorial - team

    Maintain separation in php code - Write safe code in PHP

  • Maintaining separation between validated and un-validated data helps prevent you make mistakes.
  • php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax

    Accumulate errors.. - Catch Errors

      $errors = 0;
    $errmsg = ‘’;
    $clean  = array();
    if (isset($_POST[‘submit’])) {
    		if ($_POST[‘value’] is VALID) {
    			$clean[‘value’] = $_POST[‘value’];
    		} else {
           $errors++;
           $errmsg .= ‘data not valid because…’;
    		}
    		// continue testing other fields..
    }
    click below button to copy the code. php tutorial - team

    Now to action or display..

    if (form has been submitted) {
        // validate form
    }
    if (valid submission) {
        // action data
    } else {
        // (re)display form
    }
    click below button to copy the code. php tutorial - team

    if (isset($_POST[‘submit’])) && 
        $errors===0) {
        // action data
    } else {
        // (re)display form
    }
    
    click below button to copy the code. php tutorial - team

    Redisplay form in PHP

    // if (re)displaying form: print
    // error message if redisplaying
    if ($error>0) {
    	echo “<p>errors: $errmsg</p>";
    }
    click below button to copy the code. php tutorial - team

    <label for=“email">Email:</label>
    <input name=“email" 
           size="40" 
           value="<?php echo
                        isset($clean[‘email']) ?
                 htmlentities($clean[‘email']) : 
                        ‘default'; ?>" 
           id=“email" 
           type="text“ />
    click below button to copy the code. php tutorial - team

    php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax - php tutorials
    This tutorial provides the following details on the system such as php tutorial for beginners , php for beginners , tutorial php , php website , learn php online , php programs , php programming language , php xml , php online course , php mysql tutorial , php tutorial for beginners with examples pdf , php example , php training , php source code , php 7 tutorial , php course , tutorialspoint php , learn php pdf , php application , php url , search php , script php , php & , php database , advanced php tutorial , php app , php now , php web development , php site , php book , php javascript , php this , upload php , php ajax tutorial , php lernen , php code generator , php for dummies , php generator , php in html apache php mysql

    Related Searches to What is php