Object Property Scope-Collection of common programming errors
I want to declare a private variable inside class which I want to access in all of my class without passing it to another function using parameter. I have following scenario
class One extends CI_Controller {
private $name;
public function index () {
$name = $this->input->post('name');
$this->validate();
}
public function validate() {
echo $name;
}
}
But my above $name variable gives me an error saying variable $name is undefined
.
Is above possible in PHP if yes then how?
Originally posted 2013-11-09 21:06:31.