how to check if string is valid for uudecode

264 Views Asked by At

I would like to check if $sTring is encoded before using 'convert_uudecode', and output nothing if $sTring is not. I got a PHP warning: "...The given parameter is not a valid unencoded string in...", unless I encoded $sTring correctly. Is there anyway to check $sTring before using convert_uudecode or prevent the PHP warning, if it is not encoded?

try{
    $sTring='hello';
    echo convert_uudecode($sTring);
}catch(Exception $e){}

thank you

1

There are 1 best solutions below

0
On

found a method by using warning suppression '@':

if(@convert_uudecode($sTring))echo convert_uudecode($sTring);

I am not going to vote my own answer, hoping that someone would post other, better answers