Search code examples
phphtmlinspect-element

Why "inspect element" shows different code?


I have a php page where I have the code posted below. My main problem was that in the header there was a line added at the top. This line was not added at the other .html files of my page that used exactly the same code. The only difference was the extension (html and php).

I tried "inspect element" feature to see what is going on. And I can see a different code in the <head> and the <body>.

My page code :

<!DOCTYPE html>

<?php
session_start();
include("conf.php");
$current="gallery.php"
?>

<html lang="en">
     <head>
     <title>.......</title>
     <meta charset="utf-8">
     <link  rel="stylesheet" media="screen" href="......css">

        <!-- JS -->
     <script src=".................."></script>

     </head>
<body>
<!--==============================header=================================-->

<header>
  <div class="container_12">
    <div class="grid_12">
        <h1><img src="images/logo.png">  </h1>
        <div class="menu_block">
          <nav>
            <ul class="sf-menu">
           <li><a href="index.html">ΑΡΧΙΚΗ</a> </li>
                    ...
                    ...
                   <li><a href="index-4.html">ΕΠΙΚΟΙΝΩΝΙΑ</a> </li>
            </ul>
          </nav>
          <div class="clear"></div>
        </div>
       </div>
  </div>
</header>

... 
...
</body>

What causes that ? I have the same html code (and css) in the other pages (different extension though) like this one : HTML version


Solution

  • Your webserver is set up to only interpret files with .php extension as PHP scripts. Whenever you give the page the .html extension, it will just send the file to the browser to interpret, without parsing it beforehand. So everywhere you use php code you should give the file the .php extension (or change the webserver's configuration, but I wouldn't do that now).