自动加载变量

时间:2014-03-17 10:48:00

标签: php laravel-4

laravel 4应用程序有多种形式,

在下面的示例中,如果validate的值为$register

,如何使函数$form加载register规则
class Validation  {



private $register = array(

        "nick" => "required|min:2",
        "name" => "required|min:2",
        "surname" => "required|min:2",
        "day" => "required",
        "month" => "required",
        "year" => "required",
        "country" => "required",
        "address" => "required",
        "city" => "required",
        "postalCode" => "required",
        "email"     => "Required|Between:3,64|Email",
        'password'  =>'Required|AlphaNum|Between:6,32|Confirmed',
        'password_confirmation'=>'Required|AlphaNum',
        "currency" => "required",
        "language" => "required"

);

private $support = array(

         "text"=>"required",
         "subject"=>"required"

);



public static function validate($input,$form) {

    return Validator::make($input, $form);

}

1 个答案:

答案 0 :(得分:0)

自己找到答案 - 使用变量变量

http://php.net/manual/es/language.variables.variable.php

public static function validate($input,$form) {



        return Validator::make($input,self::$$form);

}