當我替換'。$ content()'。用「Test」這樣的字符串在正確的位置在頁面中間打印「Test」。但是當我使用變量'。$ content()'。它會在頁面的左上角打印「測試」。 (請參閱課程頁面中的返回)。PHP返回函數在頁面頂部打印文本
我已經使用了這種「返回方法」很多次,這是它第一次不起作用。
我想使用$ content變量它是如何在腳本中,但我想在正確的地方輸出。
蒂莫
core.php中
class site {
function __construct($title,$content) {
echo ' <html>
<head>
<title>'.$title.'</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<link href="core/assets/css/main.css" type="text/css" rel="stylesheet">
</head>
<body>
<header id="header">
<div class="container">
<h1>DataBaas</h1>
<h2>Baas over je data</h2>
</div>
</header>
<div class="content">
<div class="article">
'.$content().'
<div>
</div>
</body>
</html>';
}
}
class pages {
function home() {
return 'Test';
}
}
的index.php是這樣的:
<?php
include_once("core/core.php");
$pages = new pages;
$thispage = $pages->home();
$site = new site('Home',function(){global $thispage; echo $thispage;});
?>
這真的是真的錯了.. –