You use a method (functions in objects are called methods), which are the same name as the class. This is called a constructor; it has special meaning in OOP.
, , . , , new classname.
$test = new myClass(123);
. , . . , new myClass .
, . :
<?php
class myClass {
var $input;
var $output;
function someOtherFunctionName($input) {
$output = 'You entered: ' . $input;
return $output;
}
}
$test = new myClass;
echo $test->someOtherFunctionName(123);
?>
, , , PHP 5 __construct() , :
<?php
class myClass {
var $input;
var $output;
function __construct($input) {
$this->input = $input;
}
}
PHP 5 manual.