I've used procedural for sometime now and trying to get a better understanding of OOP in Php. Starting at square 1 and I have a quick question ot get this to gel. Many of the basic examples show static values ( $bob->name = "Robert";) when assigning a value, but I want to pass values... say from a form ( $name = $_POST['name']; )
class Person {
// define properties
public $name;
public $weight;
public $age;
public function title() {
echo $this->name . " has submitted a request ";
}
}
$bob = new Person;
// want to plug the value in here
$bob->name = $name;
$bob->title();
I guess I'm getting a little hung up in some areas as far as accessing variables from within the class, encapsulation & "rules", etc., can $name = $_POST['name']; reside anywhere outside of the class or am I missing an important point?
Thanks