Is this in PHP 4, if so you should use references:
PHP Code:
<?php
//PHP 4
class comment{
function select_all(){
// I should return all comments from the database.
$ret = Array(); // create blank array
// code here o get comments
foreach ($comments as $comment) {
$ret[] = & new Comment($comment); // use the & operator to make it a reference
}
return $ret;
}
}
?>
In PHP 5 references are automatic:
PHP Code:
<?php
//PHP 5
class comment{
public function select_all(){
// I should return all comments from the database.
$ret = Array(); // create blank array
// code here to get comments
foreach ($comments as $comment) {
$ret[] = new Comment($comment); // no reference needed
}
return $ret;
}
}
?>