Page 1 of 1
input validation
Posted: Mon Nov 25, 2002 10:08 am
by leeo
elo are there any good functions to aid in validation
like in C i use isalpha() and in java i can use isLetter()
i have my variable as a string but how can i turn this into an array to deal with character validation just some good pointers required as i know the theory just not the good functions to use
on this note any good places to find out this info, some reference or summit like java docs gives me.
all help welcome
o yes im new to php

Posted: Mon Nov 25, 2002 10:18 am
by twigletmac
Posted: Mon Nov 25, 2002 1:39 pm
by leeo
ty m8 good bit of help im now stuck though
Code: Select all
function isLengthWithinRange($input_string, $max_length, $min_length){
$sof = count($input_string);
if($sof>$max_length || $sof < $min_length){
echo "size out of bounds<br>";
echo $sof;
return FALSE;
}
else{
return TRUE;
}
}
as you can see im trying to validate range (sof) seems to always be 1 i thought the count() function returned the number of elements in the input_string variable.
what am i doing wrong?
also a little explaining as to hoe this conversion is achieved although this is probs the answer hehe.
Leeo
Posted: Mon Nov 25, 2002 2:08 pm
by Crashin
Try using the strlen() function instead of count.
http://www.php.net/manual/en/function.strlen.php
Enjoy!

Posted: Mon Nov 25, 2002 2:15 pm
by leeo
Thats what i like straight forward replies works a treat ty m8
Posted: Mon Nov 25, 2002 2:19 pm
by BigE
You still might be interested in checking out the manual. I suggest checking out empty() php.net/empty and is_string() php.net/is_string They are both good for validation purposes.
Posted: Mon Nov 25, 2002 2:58 pm
by leeo
n1 lads ive added those extra 2 now
i am looking at the manual but it takes a while to get into it didnt even notice the string functions at first
starting to enjoy this php still havent mastered the class yet
Leeo