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

[Résolu] comment tester la nature d'une 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: French
View previous topic :: View next topic  
Author Message
truemistress
Smarty n00b


Joined: 26 Jan 2007
Posts: 2

PostPosted: Fri Jan 26, 2007 12:31 pm    Post subject: [Résolu] comment tester la nature d'une variable Reply with quote

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
View user's profile Send private message
truemistress
Smarty n00b


Joined: 26 Jan 2007
Posts: 2

PostPosted: Fri Jan 26, 2007 1:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
sinople
Smarty n00b


Joined: 03 May 2007
Posts: 1

PostPosted: Thu May 03, 2007 6:47 am    Post subject: Reply with quote

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
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: French 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