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
582 views
in Technique[技术] by (71.8m points)

html - PHP Include not working

I am trying to use PHP's include function in conjunction with html but it is not working. I'm just messing around with the tag, it seems to be very simple but i cannot figure out why it is not working...

here is the template.php page:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Template</title>
        <link href="css/layout.css"  type="text/css" rel="stylesheet" />
    </head>
    <body>

      <div id="wrapper">

          <?php 
           include ("include/header.php");
           include ("include/leftcolumn.php"); 
           include ("include/rightcolumn.php"); 
           include ("include/footer.php"); 
           ?> 

     </div>


    </body>
    </html>

and here is the header.php page that I am trying to include:

<header>
<p>Header.</p>
</header>

The only thing i could think of is the wrong directory, I have an include folder which is where the header.php is and referenced that in the include tag...unless I'm wrong, any tips? Thanks

directory folder image

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

http://php.net/manual/en/function.include.php you dont need to use parenthesis try :

<?php 
           include "include/header.php";
           include "include/leftcolumn.php"; 
           include "include/rightcolumn.php"; 
           include "include/footer.php"; 
           ?> 

and make sure the paths correct.

edit:

every exemple on the php manuel are dont have parenthesis.

And a question. where exectly you try to execute your php file. just in a browser or using any wamp server aplication to simulate server side action for your php ?


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

...