【问题标题】:Is there a way to print list of variables what are defined in included file in PHP?有没有办法打印 PHP 包含文件中定义的变量列表?
【发布时间】: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")
*/
?>

【问题讨论】:

标签: php variables include


【解决方案1】:

试试 index.php

<?php

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

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

【讨论】:

  • 是的,当然,但我的意思是如何打印变量的名称:"$variable1", "$variable2"
  • 对不起我的英语,更好的问题是;如何在 PHP 中打印包含文件中的变量名称?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 2016-05-31
  • 1970-01-01
  • 2021-09-28
  • 2011-08-20
  • 1970-01-01
  • 2021-04-19
相关资源
最近更新 更多