PHP包含不工作 [英] PHP Include not working

查看:88
本文介绍了PHP包含不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将PHP的include函数与html结合使用,但它不起作用。我只是搞乱标签,它似乎很简单,但我无法弄清楚它为什么不起作用...



这里是template.php page:

 <!DOCTYPE html> 
< html>
< head>
< title>模板< /标题>
< link href =css / layout.csstype =text / css =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>

这里是我想包含的header.php页面:

< header>
< p>标题。< / p>
< / header>

我唯一能想到的是错误的目录,我有一个包含文件夹的地方, header.php是和引用,在包含标记...除非我错了,任何提示?谢谢

解决方案

http://php.net/manual/en/function.include.php
你不需要使用括号试试:

 <?php 
includeinclude / header.php;
包括include / leftcolumn.php;
包括include / rightcolumn.php;
包含include / footer.php;
?>

并确保路径正确。



编辑:



每个例子都在php manuel上没有括号。



还有一个问题。你可以尝试执行你的php文件。只需在浏览器中或使用任何wamp服务器应用程序来模拟php的服务器端动作?


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

解决方案

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 ?

这篇关于PHP包含不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆