Calling a global variable cannot change the value of X
蓝翔特级**
蓝翔特级** 2018-08-12 20:01:09
0
2
1189

<?php

header("Content-type:text/html;charset=utf-8");

$x=5; // Global variables


function myTest()

{

$y=10; // Local variable

global $x;

echo "<p>Variables in the test function:<p>";

echo "Variable x is: $x";

echo "<br>" ;

echo "Variable y is: $y";

}


myTest();


echo "<p>Test function external variable:<p>";

echo "Variable x is: $x";

echo "< ;br>";

echo "Variable y is: $y"; //Output error Notice: Undefined variable:

?>


# #

蓝翔特级**
蓝翔特级**

reply all(2)
尹天仇

This is a problem with his editor. You can try it in your own editor and it will display normally

ll

.... Take a closer look. $y is a local variable. You must have made an error when echoing $y outside the function. This variable is not defined

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template