Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between client-side and server-side programming

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 137
    Comment on it
                   |
                   ---------->
                  HTTP request
                        |
    +--------------+    |    +--------------+
    |              |    |    |              |
    |    browser   |    |    |  web  server |
    | (JavaScript) |    |    |  (PHP etc.)  |
    |              |    |    |              |
    +--------------+    |    +--------------+
                        |
      client side       |      server side
                        |
                   <----------
              HTML, CSS, JavaScript
                        |
    

    Execution of PHP takes place on the server, resulting into output of some HTML and JavaScript code. These are meant for the client where the HTML is interpreted and the JavaScript is executed. After the end of response output by PHP, there comes an end to script, and thereafter, no activity takes places on server until the arrival of a new HTTP request.

    Below is the example:

    <script type="text/javascript">
        var foo = 'bar';
        <?php
            file_put_contents('foo.txt', ' + foo + ');
        ?>
    
        var baz = <?php echo 42; ?>;
        alert(baz);
    </script>
    

    Step 1, PHP executes all code between <?php ?> tags. The result is this:

    <script type="text/javascript">
        var foo = 'bar';
    
        var baz = 42;
        alert(baz);
    </script>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: