【发布时间】:2015-01-25 12:15:04
【问题描述】:
<?php
// this is test.php
$variable1 = "test1";
$variable2 = "test2";
?>
是否可以在“index.php”中打印这些变量名的列表?
<?php
// this is index.php
$variable3 = "test3";
$variable4 = "test4";
include("test.php");
/* Here print names of variables from "test.php" somehow...?
(Only "$variable1", "$variable2")
*/
?>
【问题讨论】:
-
get_defined_vars()可以帮助:php.net/manual/en/function.get-defined-vars.php