HOW

PHP
WORKS ?
Client
                User requests a PHP page or a HTML page that includes a PHP
                Script                                                                     Web Server
Hello world I   Via HTTP.
am a PHP Code
                  Server responds to the request by sending the generated
                  HTML page to the User.                                                                <html>
                                                                                                        <head>
                                                                                                           <title> PHP to
                                                                                                        HTML</title>
                                                                                                        </head>
                                                                                                        <body>
                                                                                                               <h1> Hello world
                                                                                                        I am a PHP
                                                                                                        Code </h1>
                                            If a PHP page is requested, server passes                   </body>
                                            the PHP page to the PHP script engine.                      </html>

                                             #hello world PHP script.
                                                                                                        The    PHP       engine
                                             <?php
                                                                                                        parses the given
                                             echo ‚<h1> Hello World I am a PHP                          PHP      script    and
                                             Code</h1>‛;                                                Converts it into HTML
                                             ?>
                                                                                                        And send’s it to the
                                                                                                        browser as shown
                                                                                                        Above.
                                                                                   PHP SCRIPT ENGINE
Client
           User requests a PHP page or a HTML page that includes a PHP
           Script                                                                            Web Server
Robinson   Via HTTP.

             Server responds to the request by sending the generated
             HTML page to the User.                                                                       <html>
                                                                                                          <head>
                                                                                                             <title> PHP to
                                       If a PHP page is requested, server passes
                                                                                                          HTML</title>
                                       the PHP page to the PHP script engine.                             </head>
                                                                                                          <body>
                                       #DataBase PHP script.                                                   <h1> Robinson</h1>
                                       <?php                                                              </body>
                                       $q = ‘SELECT fn FORM persons’;                                     </html>
                                       //run the query
                                       $r = mysqli_query($dbc, $q);
                                       //fetch the data
                                       While($re = mysqli_fetch_array($r)){
                                           echo ‚<h1>{$re[‘fn’]}</h1>‛;                                   The    PHP       engine
                                       }                                                                  parses the given
                                       ?>                                                                 PHP      script    and
                                                                                                          Converts it into HTML
                                                                                                          And send’s it to the
                               PHP engine send’s the query to the MySQL DB engine.                        browser as shown
                               (SELECT fn FROM persons);                                                  Above.
                                                                                     PHP SCRIPT ENGINE


                                  Returns the result of the query (Robinson)
              DATABASE

How php works

  • 1.
  • 2.
    Client User requests a PHP page or a HTML page that includes a PHP Script Web Server Hello world I Via HTTP. am a PHP Code Server responds to the request by sending the generated HTML page to the User. <html> <head> <title> PHP to HTML</title> </head> <body> <h1> Hello world I am a PHP Code </h1> If a PHP page is requested, server passes </body> the PHP page to the PHP script engine. </html> #hello world PHP script. The PHP engine <?php parses the given echo ‚<h1> Hello World I am a PHP PHP script and Code</h1>‛; Converts it into HTML ?> And send’s it to the browser as shown Above. PHP SCRIPT ENGINE
  • 3.
    Client User requests a PHP page or a HTML page that includes a PHP Script Web Server Robinson Via HTTP. Server responds to the request by sending the generated HTML page to the User. <html> <head> <title> PHP to If a PHP page is requested, server passes HTML</title> the PHP page to the PHP script engine. </head> <body> #DataBase PHP script. <h1> Robinson</h1> <?php </body> $q = ‘SELECT fn FORM persons’; </html> //run the query $r = mysqli_query($dbc, $q); //fetch the data While($re = mysqli_fetch_array($r)){ echo ‚<h1>{$re[‘fn’]}</h1>‛; The PHP engine } parses the given ?> PHP script and Converts it into HTML And send’s it to the PHP engine send’s the query to the MySQL DB engine. browser as shown (SELECT fn FROM persons); Above. PHP SCRIPT ENGINE Returns the result of the query (Robinson) DATABASE