|
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 |
truemistress Smarty n00b
Joined: 26 Jan 2007 Posts: 2
|
Posted: Fri Jan 26, 2007 12:31 pm Post subject: [Résolu] comment tester la nature d'une variable |
|
|
Bonjour,
Ma question est plutot simple, mais je n'ai pas réussi à trouver de réponse sur le forum, ni dans l'aide.
Comment fait-on pour tester la nature d'une variable smarty ?
Concretement, je voudrais savoir si le contenu d'une variable est du type numérique (un chiffre, entier dans mon cas) ou si ce sont des caractères (lettres, -;:/_ etc..)
(j'ai bien pensé à faire un test de si la variable est paire ou impaire, et si c'est non dans les 2 cas, j'en conclue que la variable n'est pas numérique... mais j'me dis qu'il doit y avoir une solution + directe, non ?)
Merci !
Last edited by truemistress on Fri Jan 26, 2007 4:12 pm; edited 2 times in total |
|
Back to top |
|
truemistress Smarty n00b
Joined: 26 Jan 2007 Posts: 2
|
Posted: Fri Jan 26, 2007 1:34 pm Post subject: |
|
|
c'est ok, en fait j'ai tout simplement utilisé la fonction php "is_numeric" (car le test de paire ou impaire ne fonctionne pas). |
|
Back to top |
|
sinople Smarty n00b
Joined: 03 May 2007 Posts: 1
|
Posted: Thu May 03, 2007 6:47 am Post subject: |
|
|
Attention la fonction is_numeric() te retournera vrai si ta variable est un entier ou un réel.
tu peux utiliser ctype_digit() pour vérifier qu'une chaîne de texte soit uniquement un entier. |
|
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
|