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