Jump to content

Resolve scope issues?


Perad

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.