是否有可能在PHP中延迟变量实现(?)/承认(?)?
问题描述:
a.php只会(配置文件):
<?php
$a = array('name'=>'wine[$index][name]',
'value'=>'wine[$index][value]'
)
?>
B.php:
include_once(a.php)
...
//for simple
$index = 0;
$b = $a;
//actual code like
foreach($data as $index=>$value)
$b += $a
我知道这个例子将无法正常工作,只是为了交代,我想要是否有可能(如果可能的话,怎么做?)在$ b = $ a时延迟变量$ index来取值?
答
使 “一” 的功能
function a($index) { global $data; return $data[$index] ... }
$b = a($index);
+0
不是全球性的坏事吗? – 2010-04-02 15:31:02
@Relax为$ B = $一个与$ b等于$ a或你要为$ B与$ a的值? – 2010-04-02 17:21:25
后者,实际代码就像foreach($ data为$ index => $ value)$ b + = $ a – Edward 2010-04-03 03:44:39