Constructing a Response

Let's find out what goes inside the body of a response.

We'll cover the following

Response body

In the case of random.php, almost everything that is inside this file will be added to the response body, except for what is between <?php and ?>. The PHP server will interpret the code in between these “tags”, and if anything in that code calls echo, it will add the echo-ed value to the response body too.

You can go in and out of “PHP mode”, by using the opening and closing PHP tags (<?php and ?>). You can even wrap part of the HTML inside an if statement if you like. Try the following code for instance:

Get hands-on with 1400+ tech skills courses.