Answers for "how to set global variable with function php"

PHP
2

globals in php

$GLOBALS['a'] = 'localhost';

function body(){

    echo $GLOBALS['a'];
}
Posted by: Guest on October-17-2021
3

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

Code answers related to "how to set global variable with function php"

Browse Popular Code Answers by Language