 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
bimal Smarty Elite

Joined: 19 Apr 2007 Posts: 419 Location: Kathmandu, Nepal
|
Posted: Thu Feb 23, 2012 2:42 pm Post subject: Amazing issue with modifier - comparision fails |
|
|
| Code: |
/**
* HTML PRE writing
*/
function smarty_modifier_pre($html='', $nl2br='N')
{
if($nl2br=='Y' || $nl2br==true)
{
return nl2br($html);
}
else
{
return '<pre>'.$html.'</pre>';
}
} |
I am sure there is nothing wrong with my plugin.
But when I use the following template code, I get the results of nl2br(), instead of <pre>...</pre>.
| Code: | | {$identifiers.identifier_sql|pre} |
When I compare the true with tripple equals, it is ok, === as:
... if($nl2br=='Y' || $nl2br===true) ...
Did I mistake anything logically? _________________ Skype: pbimal
To hire instantly as a freelancer - https://www.odesk.com/o/profiles/users/_~~657b70cc7f2c616a/
Visit my website - http://bimal.org.np/ for more articles
800+ screenshots to learn about website mistakes: http://mistakes.sanjaal.com/ |
|
| Back to top |
|
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 521
|
Posted: Thu Feb 23, 2012 2:47 pm Post subject: Re: Amazing issue with modifier - comparision fails |
|
|
I think 'N' == true.
also
| Code: |
if ('N')
echo "true";
|
would output "true".
Why not just use true and false instead of 'Y' and 'N'? |
|
| Back to top |
|
bimal Smarty Elite

Joined: 19 Apr 2007 Posts: 419 Location: Kathmandu, Nepal
|
|
| 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
|