0
我有一個直接調用時可以使用的匿名函數。然而,當我嘗試從另一個匿名函數調用它,我得到的錯誤從另一個調用匿名函數
致命錯誤:函數名必須是...(文件名)
下面的字符串是完整的代碼。感謝有關爲什麼這是失敗的任何想法。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
$ringW = 16; $ringCx = 8;
$ringH = 16; $ringCy = 8; $ringR = 7;
$penWidth = 2;
$svgCircle = function ($fillColor, $ringColor)
use ($ringW, $ringH, $ringR, $ringCx, $ringCy, $penWidth) {
echo "<svg width=\"$ringW\" height=\"$ringH\">";
echo "<circle cx=\"$ringCx\" cy=\"$ringCy\" r=\"$ringR\" " .
"stroke=\"$ringColor\" stroke-width=\"$penWidth\" fill=\"$fillColor\" />\n";
echo "</svg>\n";
};
$pac = function ($condition) {
if ($condition)
// echo "Hello world\n"; // pass
$svgCircle("yellow", "green"); // fails
};
?>
<head>
<title>LVCC Algorithm</title>
</head>
<body>
<?php
$pac(1);
$svgCircle("yellow", "green"); // pass
$svgCircle("yellow", "green");
?>
</body>
</html>
什麼是'$ pac'功能範圍有多大? –
應該與svgCircle相同 - 否則我沒有指定任何內容。不知道我是否需要在這裏做點什麼,因此問題:) –