experienced C++, new to php, question:
I am following the tutorial at killerphp, using the following code..
<?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;
}
}
?>
and...
<?php
$stefan = new person("Stefan");
echo "Stefan's full name: " . $stefan->get_name();
?>
The echo statement does not print the name set by the constructor. It works fine when using a set_name() function. What am I missing?
I think I'm using version 4.x? of php.