PHP包含变量

时间:2017-11-08 18:13:19

标签: php variables

我已创建了这两个文件,但它无法正常工作,请您更正我的代码?我是PHP的新手,所以请不要责怪我......谢谢!

最终档案:

<?php 
include 'template.php';

$show = "The Flash";
$episode_name = "Pilot";

$season = "01";
$episode = "01";
?>

模板:

<?php echo $show; ?>

1 个答案:

答案 0 :(得分:-1)

尝试包括?

<?php 

$show = "The Flash";
$episode_name = "Pilot";

$season = "01";
$episode = "01";

include 'template.php';
?>

在我的服务器上我做了: 的index.php

<?php
  $title = "Test";
  $template = "./template.php";
  include $template;
?>

的template.php

<?php echo $title; ?>

它工作得非常好。它回应&#34;测试&#34;