PHP包含不工作 [英] PHP Include not working
问题描述
我试图将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屋!