PHP Hello World Class
From Resin 3.0
Introduction
Since PHP 3.0, there has been some support for object-oriented programming. The following sample PHP code shows how to:
- define a class
- instantiate that class
- call methods on the instance of the class
SamplePHPClass.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body> <?php class Foo { var $bar; function setBar($value) { $this->bar = $value; } function someFunction($param) { echo $param.$this->bar."
"; } } $foo = new Foo(); $foo->setBar("Charles"); $foo->someFunction("Hello, "); ?> </body> </html>