Undefined variable problem with PHP function

前端 未结 5 1989
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 08:06

I\'m a PHP newbie, so I have a minor problem functions. I have this line of code:



        
5条回答
  •  长情又很酷
    2020-11-27 08:26

    It sounds like you have nothing set in your $pera variable. If you have to define a variable outside a function, try passing its value as argument to your function.

    function echoMyVar( $myVar )
    {
       echo $myVar;
    }
    
    
    $p = "toto";
    echoMyVar($p);
    

提交回复
热议问题