Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
751 views
in Technique[技术] by (71.8m points)

html - Why does my PHP appear to be commented out when I view it in the browser? <!--?php include("header.php"); ?-->

I am building a html page but want to break the header out so I dont have to keep changing all the files.

I am attempting to add a php.include file and save the pages out as .php files.

For some reason the header.php file is not showing in my file when i view it.

here is my code. Is this the correct way??

<!DOCTYPE html>

<html lang="en">

    <head>
    <meta charset="utf-8" />
    <title>Chartego | Creating Socially Inflential People with great images and videos</title>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

</head>
<body>

<?php include 'header.php'; ?>


  <div id="wrap-inner">
content
</div>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

when i inspect the element using chrome the php seems to be commented out

The PHP is not passing through a PHP parser before getting to the browser, so the browser is receiving the PHP code instead of the server executing it.

Make sure that:

  • You are loading the page over HTTP (e.g. not just double clicking the file in your file manager)
  • The server you are using supports PHP
  • The server is configured to treat the file as PHP (this is usually done by giving it a .php file extension)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...