1
我有以下的(总结)代码使用函数的变量外
define pauls_code($a, $b)
{
$c = $a + $b;
echo $a;
echo $b;
}
pauls_code(1,2);
echo $c; // how do I get this to print outside of the function? I have tried everything. I am hoping to see 123
为什么不从函数返回值并从外部调用函数,您如何期望从其范围内访问变量? – Fisherman 2014-10-01 08:02:20
使用'global'。或者让它成为回报。或者通过引用传递一个变量。 – Aneri 2014-10-01 08:02:43
只需返回'$ c' – Sal00m 2014-10-01 08:02:53