有没有办法打印PHP中包含文件中定义的变量列表?

时间:2014-11-27 01:04:02

标签: php variables include

<?php
// this is test.php

$variable1 = "test1";
$variable2 = "test2";
?>

是否可以在&#34; index.php&#34;中打印这些变量名称的列表。 ?

<?php
// this is index.php

$variable3 = "test3";
$variable4 = "test4";

include("test.php");

/* Here print names of variables from "test.php" somehow...? 
(Only "$variable1", "$variable2")
*/
?>

1 个答案:

答案 0 :(得分:0)

试试index.php

<?php

$variable3 = "test3";
$variable4 = "test4";

include("test.php");
echo $variable1;
echo $variable2;
?>