Question

In my index.php I have:

<?php

require_once('./headers/hed1.php');

require_once('./headers/hed2.php');

require_once('./headers/hed3.php');

echo 'TEXT';

?>

When I run this on my pc (using XAMPP) I get the result I want: the output of the three require_once, and then the TEXT.

I uploaded it to a server, and the same code has a different output. I see first the TEXT, and then the three require_once.

I saw another post of someone with the same problem, but there was no solution. Why the output id displayed in a different way if it's onlyne? Is there a way to "reorder" the three require_once?

Thanks in advanced!

Was it helpful?

Solution

Everything is OK with your code and it is echoed by the PHP properly, this is the output:

<table border="0" width=100%><tr><td>Hi!</td><td align=right><a href="index.php?login">Log in!</a>, <a href="index.php?register">Register!</a></td>main

The problem is in your HTML. It's invalid. The table is not closed. The elements are messed up. The browser simply renders it in the wrong order.

OTHER TIPS

You've not understood how your code works, how html works nor apparently made any effort to investigate why this is not producing unexpected results.

The files are being included in the correct order. The output is being generated in the correct order. Unfortunately the HTML is malformed so your browser doesn't know how to render it properly.

If you 'view source' in your rowser you'll something like the following (reformatted for readability)

<html>
  <body>
    <table border="0" width=100%>
       <tr>
         <td>Hi!</td>
         <td align=right><a href="index.php?login">Log in!</a>, 
                    <a href="index.php?register">Register!</a></td>
         main
      </body>
   </html>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top