Perad Posted November 28, 2009 Share Posted November 28, 2009 I have a custom validation library that I am making. I have hit a stumbling block. I need custom validation options. Unfortunately I cannot get the scope to work. Check it out. // User Class $this->v->class = 'User'; $this->v->set_rule('username', 'required|maxlength.30|minlength.4|callback.valid_credentials'); // Validation Class private function callback($function) { global $this->class; $this->class->$function(); } To explain. The user class extends the base class. The base class basically does global $validation; $this->v = $validation When the validation is run it explodes the rules into "function.value". So above The callback function will be executed with the function name. What I need to do is put the user class into the same scope as the validation class. Then execute the function. I tried the code above. I got the following error. Fatal error: Cannot re-assign $this in C:\xampp\htdocs\clientApp\system\classes\validation.class.php on line 59 I hope this makes sense. Do you have any ideas? Link to comment https://forums.phpfreaks.com/topic/183219-resolve-scope-issues/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.