The recent PHP versions now supports object-oriented programming or OOP, which usually are in class form. Since PHP OOP are in class form, they have accessors, mutators, data members, etc. — much like the usual OOP programming languages. Last week, we started a short crash course with Web Development with PHP/MYSQL. So, I introduced a bit of OOP since most of the participants have the idea already about OOP ( in Java, C++).
Here’s a snippet I used as a demo during our short session:
[sourcecode language='php']
class demo {
var $name;
function setName($nombre)
{
$this->name = $nombre;
}
function getName()
{
return $this->name;
}
}
$naming = new demo();
$naming->setName(“Jerome Locson”);
echo $naming->getName();
?>
[/sourcecode]
I guess if you have a background in programming, you know how the code works. And if not, just drop me comment and I am willing to answer it.


