|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
joelgriffiths Smarty n00b
Joined: 29 Aug 2004 Posts: 3 Location: Phoenix, AZ
|
Posted: Sun Aug 29, 2004 3:11 pm Post subject: register_object breaks on methods ending with number |
|
|
Apache: 1.3.31
PHP: 5.0.1
Smarty: 2.6.3
I downloaded the most recent stable version of smarty 2-3 days ago (smarty newbie). While trying to use the register_object function, I noticed that methods ending with numbers (eg. function test1()) did not execute properly. Instead, they echoed the method name back to the browser.
For instance, the code below produced the following output:
TEST
testmethod->test2
testmethod->test3
// test.php
<?php
Class test {
function test() {
return("TEST");
}
function test2() {
return("TEST2");
}
function test3() {
return("TEST3");
}
}
require('Smarty.class.php');
$smarty = new Smarty;
$testObject = new test;
$smarty->register_object("testmethod",$testObject);
$smarty->display('registerbug.tpl');
?>
// registerbug.tpl
<pre>
{testmethod->test}
{testmethod->test2}
{testmethod->test3}
</pre> |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Aug 29, 2004 3:37 pm Post subject: Re: register_object breaks on methods ending with number |
|
|
joelgriffiths wrote: | <pre>
{testmethod->test}
{testmethod->test2}
{testmethod->test3}
</pre> |
That is invalid template synatax. There are two ways to use objects in the template, either register the object or assign it like any other variable. See the docs on the correct syntax for each. |
|
Back to top |
|
joelgriffiths Smarty n00b
Joined: 29 Aug 2004 Posts: 3 Location: Phoenix, AZ
|
Posted: Sun Aug 29, 2004 3:48 pm Post subject: |
|
|
I guess I should have called the registered object testObject (not testMethod).. That was more of a naming convention problem than a bug though. testmethod was a registered object. Did I misunderstand your comment? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Aug 29, 2004 5:15 pm Post subject: |
|
|
@joelgriffiths:
this is a bug in Smarty-2.6.3 that affects methodnames and other identifiers containing digits.
it was fixed in cvs on jul 1 2004. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Aug 30, 2004 3:20 pm Post subject: |
|
|
nm, that syntax is fine. listen to messju instead |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|