PHP Global Keyword


PHP Global Keyword:– Global keyword is used in php if we want to access a global variable inside a function.


PHP Global Keyword | Example

Let us take an exampmle to understand global keyword in php.

Example

<?php

$x=10;

function play(){
	
    $y=20;
	echo $y;
	echo $x;// compile error
	echo "<br>";
	echo "hey";
	echo "<br>";
}

play();

echo $x;

echo $y;//compile error

?>



Advertisements

Add Comment

📖 Read More