PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
class foo {
function bar() {
return 'bar';
}
function printBar($sometypeofargumentfrombar()) {
print($sometypeofargument);
}
}
$foo = new foo();
$foo->bar()->printBar();
Well, is the template an object with an output() method?
Actually, to answer your question: no. You can only return one thing. Basically either a string, an integer, an array, another object, or $this (providing it's a class method).
class Template {
public $content;
public function fetch($template) {
$this->content = file_get_contents("$template.tpl");
return $this;
}
public function output() {
if(isset($this->content)) {
print($this->content);
}
return $this; //maybe needed to continue a chain
}
}
$template = new Template;
$template->fetch('header')->output();
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.