How do you access the following $x and $y inside the function without importing?


$x = 1;

$y = 2;

function myMan(){

//......? calculate $x and $y here and make $sum

}

Train Asked on January 29, 2016 in PHP.
Add Comment
  • 1 Answer(s)
    
    $x = 1;
    $y = 2;
    function myMan(){
    
    $sum = $GLOBALS['x'] +$GLOBALS['y'];
    
    return $sum;
    
    }
    
    
    Train Answered on January 29, 2016.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.