今天,我开始学习PHP.而且,我已经创建了我的第一个PHP文件来测试不同的变量.你可以看到我的文件如下.
<?php
$x=5; // global scope
function myTest()
{
$y=10; // local scope
echo "<p>Test variables inside the function:<p>";
echo "Variable x is: $x";
echo "<br>";
echo "Variable y is: $y";
}
myTest();
echo "<p>Test variables outside the function:<p>";
echo "Variable x is: $x";
echo "<br>";
echo "Variable y is: $y";
?>
Run Code Online (Sandbox Code Playgroud)
我在浏览器中运行此文件时发现以下错误.
注意:未定义的变量:第19行的/opt/lampp/htdocs/anand/php/index.php中的x
注意:未定义的变量:y在第29行的/opt/lampp/htdocs/anand/php/index.php中
任何人都可以帮我解决问题吗?
php error-handling runtime-error compiler-errors syntax-error