Jump to content

Help with a function..


jscix

Recommended Posts

How could I make this function return a true or false value depending on if the supplied string passes the checks??

 

<?php

Function ValidateString($txtcheck)
{  //start function

if ($txtcheck == (null))
{
// didn't pass because string is null
}

elseif (strlen($txtcheck) < 3)
{
// didn't pass because string is too short

}

elseif (ctype_alnum(!$txtcheck))
{
// didnt pass because string contains alphanumeric chars
}
else
{
// return true
}

} // end function

 

sorry for the easy question, still getting the hang of this stuff. :o anyone?

Link to comment
https://forums.phpfreaks.com/topic/38535-help-with-a-function/
Share on other sites

Like so...

<?php
function ValidateString($txtcheck) {
    if($txtcheck == (null)) {
        return false;
    } elseif(strlen($txtcheck) < 3) {
        return false;
    } elseif(ctype_alnum(!$txtcheck)) {
        return false;
    } else {
        return true;
    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/38535-help-with-a-function/#findComment-184952
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.