1°解決方案:你需要改變你的代碼爲:
<?php include_once 'boot.inc' ?>
<?php include_once 'template.php' ?>
<div class="widget">
<div class="widget-title"><?php echo $title; ?></div>
<div class="widget-body"><?php echo $content; ?></div>
</div>
在template.php
文件,則必須有這樣的事情:
<?php
$title="My Title";
$content="My Content";
?>
而且你不需要的功能爲這個事業變量存儲在template.php
2°解決方案:您需要實施TA功能來從外部源變量:
<?php include_once 'boot.inc' ?>
<?php include 'functions.php' ?>
<div class="widget">
<div class="widget-title"><?php echoTitle(); ?></div>
<div class="widget-body"><?php echoContent(); ?></div>
</div>
在functions.php
<?php
function echoTitle(){
$title = 'Add code to get title here';
echo $title;
}
function echoContent(){
$content = 'Add code to get content here';
echo $content;
}
更換Add code to get title here
和Add code to get content here
用代碼來獲取內容例如:
$title = $_POST['title'];
假如你希望通過提交表單拿到冠軍
我沒有足夠的細節來告訴你更多。
你試過把'<?php echo $ title; ?>它在哪裏說「我需要在這裏放置標題」,以及'include'template_file.php';'作爲你的函數的主體? – Kenney
是的,它說:「我需要在這裏放置標題/內容」它需要由'$ title'和'$ content'從函數參數值替換 –
對不起,我在noobie中使用php。你可以發佈代碼示例嗎? –