【发布时间】:2016-06-09 03:19:09
【问题描述】:
我有一些 PHP 变量,它们的名称直接链接到它们所包含的函数。
是否可以自动创建这些变量,以便我可以使用所有变量 00-200?
这就是我现在正在做的……
$regdays00 = is_user_reg_matured( 00 );
$regdays02 = is_user_reg_matured( 02 );
$regdays05 = is_user_reg_matured( 05 );
$regdays08 = is_user_reg_matured( 08 );
我很想去:
small function that creates all $redays000 - $regdays200
if ( $regdays162) { "This has now used is_user_reg_matured(162)" }
谢谢!
【问题讨论】:
-
不行! 不要那样做。使用数组或其他东西,但不要仅使用递增的数字创建 200 个变量。
-
为什么要创建这么多变量,只使用一个数组
-
我对数组不熟悉...你能举个例子吗?
-
@Scott Google
PHP array和PHP for并阅读手册页。这些是一些基本的东西,所以请确保你真正理解它们:) 这样你的代码会更好。 -
非常感谢!