Welcome Guest, Not a member yet? Register   Sign In
Is the helper function can't use another param variable which aren't defined in the function name?
#1

[eluser]OneCorea[/eluser]
$this->load->helper('myhelper');

in myhelper.php file
Code:
// if blank string returns 1
function is_blank($str){
    $temp=str_replace("\n","",$str);
    $check=0;
    for($i=0;$i<strlen($temp);$i++)
    {
     if($temp[$i]=="<") $check=1;
     if(!$check) $temp2.=$temp[$i];
     if($temp[$i]==">") $check=0;
    }
    if(eregi("[^[:space:]]",$temp2)) return 0;
    return 1;
}

when I try to this my own helper function CI displays error as belows..

Code:
Message: Undefined variable: temp

temp, temp2 is not param which is defined function name parameter..

What is wrong????
#2

[eluser]alexsancho[/eluser]
try this instead

Code:
function is_blank($str){
    $temp=str_replace("\n","",$str);
    $check=0;
    $temp2='';
    for($i=0;$i<strlen($temp);$i++)
    {
     if($temp[$i]=="<") $check=1;
     if(!$check) $temp2.=$temp[$i];
     if($temp[$i]==">") $check=0;
    }
    if(eregi("[^[:space:]]",$temp2)) return 0;
    return 1;
}




Theme © iAndrew 2016 - Forum software by © MyBB