在php变量中使用html中的php include函数
我正在做这样的事情在php变量中使用html中的php include函数,php,html,include,Php,Html,Include,我正在做这样的事情 $some_var='<!DOCTYPE html> <head> <title>questions '.$suto.'</title> <meta charset="utf-8" /> <meta name="description" content="question need to'. $
$some_var='<!DOCTYPE html>
<head>
<title>questions '.$suto.'</title>
<meta charset="utf-8" />
<meta name="description" content="question need to'. $suto.'">
'. include ("header.php") .'
<body>
$some\u var='1
问题:“$suto”
'.include(“header.php”)。'
下面有更多的代码正在运行,这就是为什么不在这里发布的原因
一切都可以使用include函数。而不是include()
您可以使用file\u get\u contents()
类似
$some_var='<!DOCTYPE html>
<head>
<title>questions '.$suto.'</title>
<meta charset="utf-8" />
<meta name="description" content="question need to'.$suto.'">'.file_get_contents("header.php").'
<body>
$some\u var='1
问题:“$suto”
.file_get_contents(“header.php”)。'
file\u get\u contents()
是一个PHP函数,它是将文件内容读入字符串的首选方法之一
include()
将解析包含文件中的PHP代码。而file\u get\u contents()
将返回文件的内容。在这里,您将内容存储为字符串。因此,文件获取内容是正确的选择。您可以使用文件获取内容功能()
$some\u var='1
问题:“$suto”
“.file获取内容(“header.php”)。”
';
ty-jenz它可以工作,但为什么包含函数在这种情况下失败case@sukhjitdhot..Sorry因为耽搁了。请查看我的更新答案以了解更多详细信息。谢谢jenz file get contents(“../header.php”)不起作用。您能否建议如何从以前的目录中选择标题?如果header.php位于下面的文件夹中,则(“../header.php”)应该起作用。这正是我所希望的,但由于某些原因它不起作用。
$some_var='<!DOCTYPE html>
<head>
<title>questions '.$suto.'</title>
<meta charset="utf-8" />
<meta name="description" content="question need to'. $suto.'">
'. file-get-contents ("header.php") .'
<body>';