Skip to content

Instantly share code, notes, and snippets.

View rasoulvatanparast's full-sized avatar

Rasoul Vatanparast rasoulvatanparast

View GitHub Profile
<?php
$x=5;
$y=7;
$sum=$x+$y;
echo $sum;
?>
<?php
$x=5;
$y=7;
echo $x+$y;
?>
<?php
$xVar = 10;
function test(){
echo $xVar;
}
echo $xVar;
<?php
$xVar = 10;
function test(){
echo $xVar;
}
echo $xVar;
test();
<?php
$x = 10;
function test(){
echo $GLOBALS['x'];
}
test();
<?php
function test(){
$x = 10;
echo $x;
}
test();
echo $x;
<?php
function test(){
$x = 10;
echo '<p>' . $x . "</p>\n";
}
function test2(){
$x = 5;
echo '<p>' . $x . "</p>\n";
<?php
$x = 10;
function test(){
global $x;
echo $x;
}
<?php
$x = 10;
$y = 15;
function test(){
global $x, $y;
$x = $x * $y;
}
<?php
$x = 10;
$y = 15;
function test(){
$GLOBALS['x'] = $GLOBALS['x'] + $GLOBALS['y'];
}