Dynamic Web Pages

Derek Bridge

Department of Computer Science,
University College Cork

Dynamic Web Pages

Aims:

Terminology

PHP: our programming language for first-year students

Programming languages and scripting languages

Static vs. dynamic web pages

Static web pages

A client requests a static Web page. The server retrieves it form its disk and sends a copy back to the client.

Static vs. dynamic web pages

Dynamic web pages

A client requests a dynamic Web page. The server retrieves a pogram from its disk. It executes the program. The output of the program is sent back to the client.

greetings1.php: our first PHP script

<?php 
    echo 'Hello world!'; 
?>

Notes on greetings1.php

Notes on greetings1.php

greetings2.php: our second PHP script

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Our second PHP script</title>
    </head>  

    <body>

        <p>
            <?php 
                echo 'Hello world!'; 
            ?>
        </p>

    </body>
</html>

Notes on greetings2.php

Notes on greetings2.php

Distinguish:

greetings3.php: our third script, which outputs tags

…
<body>

    <p>
        <?php 
            echo '<strong>Hello world!</strong>'; 
        ?>
    </p>

</body>

Our fourth script (news.php): something less pointless

…
<body>

    <header>
        <?php
            echo date('D F j Y, h:i:s a');
        ?>
    </header>
    
    …
    
<body>

Notes on news.php