Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

non-case-sensitive Variable

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
rok°!
Smarty Rookie


Joined: 10 Jan 2005
Posts: 12

PostPosted: Mon Jan 10, 2005 7:32 pm    Post subject: non-case-sensitive Variable Reply with quote

Hallo!

Wie frage ich eine non-case-sensitive Variable ab?

if ($var eq "hallo" || $var eq "HALLO" || $var eq "hALLO")

ist doch viel zu lang.
kann mir da jemand helfen?
Back to top
View user's profile Send private message
CaptainE
Smarty Rookie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Tue Jan 11, 2005 10:55 am    Post subject: Reply with quote

hi, also z.b. du machst das so:

Code:
{if strtolower($var) == "hallo"}


dann ist es egal wie das in var ankomt, dann wird es in kleinbuchstaben umgesetzt und jede schreibweise von hallo wird erkannt.

zu beachten inst natürlich dass das argument das verglichen wird auch komplett klein geschrieben wird.
Back to top
View user's profile Send private message
rok°!
Smarty Rookie


Joined: 10 Jan 2005
Posts: 12

PostPosted: Tue Jan 11, 2005 11:06 am    Post subject: Reply with quote

das ist doch aber php. ich wollte keinen phpcode in den templates verwenden.
oder geht das auch mit smarty?
Back to top
View user's profile Send private message
CaptainE
Smarty Rookie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Tue Jan 11, 2005 11:57 am    Post subject: Reply with quote

also zum einen, ich weiß nicht ob smarty dafür selbst eine funktion hat, glaube es aber ehrlich gesagt nicht

zweitens. naja, es ist eine phpfunktion, das ist schon richtig, aber da die smarty templates vor der ausführung ja in php compiliert werden ist das doch absolut kein problem. Wenn es eine Smaryfunktion geben würde die genau das macht, würde sie beim compilieren durch diese erstzt werden, daher sehe ich darin absolut kein problem. und abgesehen davon bassiert smarty nunmal auf php und deshalb wirst du nicht umhin kommen hin und wieder php funktionen direkt in templates einzusetzen, was ja auch so gedacht ist.
Back to top
View user's profile Send private message
rok°!
Smarty Rookie


Joined: 10 Jan 2005
Posts: 12

PostPosted: Tue Jan 11, 2005 1:00 pm    Post subject: Reply with quote

hm, das ein templatesystem dafür gedacht ist, auch programmcode darin auszuführen bezweifele ich. denn ich nutze templates um sie vorm strikten programmcode zu schützen. (ich versuche es zumindest).

aber das sind alles grundsatzfragen. ich dachte nur mit einer sprache in den templates auskommen zu müssen, um den nutzer nicht noch weiter zu verwirren.

trotzdem danke für deine antwort!
Back to top
View user's profile Send private message
CaptainE
Smarty Rookie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Tue Jan 11, 2005 1:06 pm    Post subject: Reply with quote

ok, als das mit der trennung ist ein argument.

ich hab mich kurz nochmal informiert und es gibt dann wohl noch die folgende lösung:

Code:
{if $var|lower == "hallo"}


ist im prinzip genau das gleiche aber halt per smarty

wird dann warscheinlich beim compilieren des templates in eine strtolower umgewandelt *g*
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP