I created custom function OutputMessage from where i'm inserting error message with its ClassStyle like this Error: image upload failed! and then i'm exploding string and split class from it add in to div class but my function is not working fine.
function OutputMessage($Message=''){
if($Message){
$Postion = strpos($Message,":");
if($Postion !== TRUE){
return sprintf('<div class="alert alert-default">%s</div>',$Message);
}else{
$Message = explode(": ",$Message);
return sprintf('<div class="alert alert-%s">%s</div>',strtolower($Message[0]),$Message[1]);
}
}else{
return "";
}
}
$Position check is not working because i'm passing Message with it's class but it's still returning default class
From the manual entry of strpos() function:
which means that
if($Postion !== TRUE)will always betrue, asstrpos()never returnstrue.To make your function work as expected, change your
ifstatement toif($Postion === false).