[PHP] REQUIRE_ONCE AND CLASSES
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!
Re: [PHP] REQUIRE_ONCE AND CLASSES
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 +, 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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REQUIRE_ONCE AND CLASSES
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 +, 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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php