我有两个PHP文件。一个是action.php,另一个是include.php
我需要在我的其他脚本中回显变量形式include.php。
include.php中基本上有这个变量
$id= $web_id;
$start = "Hello, ";
$end = "works.";
在我的action.php中,我有这些变量
$web_id = "testing echo from variable in include.php";
echo $start; // variable is in include.php
echo $id; //variable is in include.php
echo $end; //variable is in include.php
结果是
Hello, works.
我想要实现的是
Hello, testing echo from variable in include.php works.
这个语法只为$ id提供了空值。在包含文件中用变量回显变量的正确语法是什么?
在进行包含之前,需要设置$web_id
变量。看看这个例子:
$web_id = 'this'.
include 'include.php';
echo $start . $id . $end;
$id = $web_id;
$start = 'Hello ';
$end = ' works.';