Re: REQUIRE_ONCE AND CLASSES
| From: | Wico de Leeuw | Date: | Mon, 16 Dec 2002 16:36:58 +0000 |
| Subject: | Re: REQUIRE_ONCE AND CLASSES | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128418@lists.php.net to get a copy of this message | ||
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(){$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!