Answers for "php globals"

PHP
1

php global variable function

<?php
  $myVariable = "a";
  function changeVar($newVar) {
    global $myVariable
    $myVariable = "b";
  }
  echo $myVariable; // Should echo b
?>
Posted by: Guest on May-16-2021
1

how make a variable global php

$a = 1;
$b = 2;
function Sum(){
    global $a, $b; // allows access to vars outside of function
    $b = $a + $b;
} 

Sum();
echo $b; // output is 3
Posted by: Guest on April-26-2021
0

php globals

$GLOBALS["foo"]
Posted by: Guest on October-21-2020
0

global phpcs

composer global require squizlabs/php_codesniffer
Posted by: Guest on April-22-2021

Browse Popular Code Answers by Language