PHP variable defined in 'parent' file not recognized in 'required' file

前端 未结 3 832
心在旅途
心在旅途 2021-01-22 22:53

I am trying to access a variable defined in parent file from inside the required file, like this:

<<< parent.php >>>

$controller = \'index\         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 23:26

    That is strange. Try to see if variable is part of defined variables:

    $vars = get_defined_vars();
    print_r($vars);
    

    Also, If your variable exists in a function, you can globalize it with global keyword.

提交回复
热议问题