There is a problem with the self-study example code
phpcn_u2188
phpcn_u2188 2017-05-15 12:43:11
0
1
492

PHP global keyword

global keyword is used to access global variables within a function.

To call a global variable defined outside a function within a function, we need to add global before the variable in the function Keywords:

Instance

<?php
$x=5;
$y=10;

fun ction myTest()
{
global $x,$y;
$y=$x $y;
}

myTest();
echo $y; // Output 15
?>



Output 15 here should be output 10, myTest() cannot output here, you should add an echo $y

phpcn_u2188
phpcn_u2188

reply all(1)
黄舟

Okay thanks for the feedback!

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