0

I am trying to create a page that outputs "no query string" if $_REQUEST is null or if $_REQUEST is not null, output a page that says "query string". Also, output the line "The query string is . var_dump($_REQUEST)."I have written the code, but am not able to get the page to load and do not know where to go from here.

<!DOCTYPE HTML>
<html>
<?php
$req = $_REQUEST;
if($req === null) { ?>
    <title>no query string</title>
    <body>
    <p>The query string is null.</p><br>
    </body>
    <?php
} ?>
<?php
else { ?>
    <title>with a query string</title>
    <body>
    <?php
    $dump = var_dump($_REQUEST);
    echo "The query string is " . $dump;
    ?>
    </body>
    <?php
} ?>
</html>
ilikecake1
  • 57
  • 7

1 Answers1

2

If you close an if statement, you have to start the else without coming out of PHP.

Just remove the closing and opening PHP tags:

 </body>
    <?php
} else { ?>
    <title>with a query string</title>

Also, $_REQUEST will never be null. It will simply be an empty array. Try empty($_REQUEST) instead.

rjdown
  • 8,530
  • 3
  • 23
  • 39