Index.php
<?php
$stefan = new person("Stefan Mischook");
echo "Stefan's full name: ".$stefan->get_name();
?>
class_lib.php
<?php
class person {
var $name;
function __construct($persons_name) {
$this->name = $persons_name;
}
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
Why even have var $name; if the code works fine without it? With the construct, would there be a need for the set_name function?