I can not understand why nothing is displayed. There is an announcement, there is a call with the parameter

$ff = 'ground zero'; function method1($a) { echo($a); } function method2 () { method1($ff); } method2(); 

    1 answer 1

    The $ ff variable is not declared inside the mathod2 method. If you want to use a global variable inside a function, explicitly declare it as global:

     $ff = 'ground zero'; function method1($a) { echo($a); } function method2 () { global $ff; method1($ff); } method2(); 

    Example

    Read more in the PHP documentation .

    • thanks, exhaustive answer - Eugene Master