Re: REQUIRE_ONCE AND CLASSES
| From: | Wico de Leeuw | Date: | Mon, 16 Dec 2002 16:40:29 +0000 |
| Subject: | Re: REQUIRE_ONCE AND CLASSES | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128422@lists.php.net to get a copy of this message | ||
Ofcourse there can only be one home function:
<?
require_once "HTML/IT.php";
class Home {
var $tpl_home = NULL;
function Home(){
$this->tpl_home = new IntegratedTemplate("../templates");
$this->tpl_home->loadTemplatefile("index.tpl.html", true, true);
$this->tpl_home->setCurrentBlock("GEREN");
$this->tpl_home->setVariable("GEREN","b");
$this->tpl_home->parseCurrentBlock("GEREN");
$this->tpl_home->setCurrentBlock("PRINCIPAL");
$this->tpl_home->setVariable("DADOS","a");
$this->tpl_home->parseCurrentBlock("PRINCIPAL");
}
function show(){
$this->tpl_home->show();
}
}
$alo=new Home();
$alo->show();
?>
At 17:36 16-12-02 +0100, Wico de Leeuw wrote:
Hiya Try it like this: <?require_once "HTML/IT.php"; class Home { var $tpl_home = NULL;function Home () { $this->tpl_home = new IntegratedTemplate("../templates"); }function Home(){$this->tpl_home->loadTemplatefile("index.tpl.html", true, true);$this->tpl_home->setCurrentBlock("GEREN"); $this->tpl_home->setVariable("GEREN","b"); $this->tpl_home->parseCurrentBlock("GEREN"); $this->tpl_home->setCurrentBlock("PRINCIPAL"); $this->tpl_home->setVariable("DADOS","a"); $this->tpl_home->parseCurrentBlock("PRINCIPAL"); }function show(){ $this->tpl_home->show(); } } $alo=new Home(); $alo->show();?> P.S. you can assign 'dynamic' content to a class var in a (class) function, not with var $var = aFunction() or something At 16:24 16-12-02 +0000, Mauro Romano Trajber wrote:Hi all. I got a problem. When i include a external file using require_once('my_file.php'); in a class file i cant use my_file´s vars and functions. Example: <? require_once "HTML/IT.php"; class Home{ var $tpl_home= new IntegratedTemplate("../templates"); function Home(){-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php$this->tpl_home->loadTemplatefile("index.tpl.html", true, true); $this->tpl_home->setCurrentBlock("GEREN"); $this->tpl_home->setVariable("GEREN","b"); $this->tpl_home->parseCurrentBlock("GEREN"); $this->tpl_home->setCurrentBlock("PRINCIPAL"); $this->tpl_home->setVariable("DADOS","a"); $this->tpl_home->parseCurrentBlock("PRINCIPAL");} function show(){$this->tpl_home->show();} } $alo=new Home(); $alo->show(); ?> DONT WORK!!! why? im new in php. i will thank any help. sorry my english!!! :) Mauro!