Undefined variable problem with PHP function

前端 未结 5 1983
隐瞒了意图╮
隐瞒了意图╮ 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:25

    You can't use $pera inside the method like that because it's not defined inside the method scope.

    If you want to use the method, pass it as a parameter.

    function provera($prom, $pera){ //passed as a param
        if (preg_match("/[0-9\,\.\?\>\.<\"\'\:\;\[\]\}\{\/\!\\\@\#\$\%\^\&\*\(\)\-    \_\=\+\`[:space:]]/",$prom)){
            echo "Nepravilan unos imena ili prezimina!";
        echo $pera;
    }
    

提交回复
热议问题