Hello,
I'm experiencing following error in my php code:
Code:
Catchable fatal error: Object of class input could not be converted to string in /home/skyer/.../class/input.php on line 16
The source code looks like this: (line 16 is the one with preg_match()
Code:
class input
{
private $id="/^[0-9]{1,4}$/";
public function Check_input($type,$input)
{
if (!isset($this->$type)) {if (DEBUG) echo 'input::Check_input():Cond1:variable doesn\'t exist'; return 0;}
if (preg_match($this->$type,$input)==0) {if (DEBUG) echo "input::Check_input($this->$type,$input):Cond2:input not of expected character";return 0;}
}
}
It seems to me that the problem is that PHP can't convert $this->$type into string, but I don't know why. $this->$type should be $this->id, and that's defined right above the function.
If I use $this->id directly instead of $this->$type, code works as expected.
Thank you for your help,
Skyer