Php throws an exception. PHP code
'Hello World',]; $ res = '20140901'; printData (check ($ res); printData (check ($ arr )); /*** Array ([line] => 21 [file] => 21 [msg] => not is array) Array ([data] => hello world) **/function check ($ x) {try {if (! Is_array ($ x) {throw new Exception ('not is array') ;}} catch (Exception $ e) {$ data ['line'] = $ e-> getLine (); $ data ['file'] = $ e-> getLine (); $ data ['MSG '] = $ e-> getMessage (); return $ data;} return $ x;} $ item = '20140901 '; $ row = ['0' => 1,]; print_r (checkString ($ item); print_r (checkString ($ row);/** Fatal error: Uncaught Exception: it is not a string in D: \ xampp \ htdocs \ phperror. php: 77 Stack trace: #0 D: \ xampp \ htdocs \ p Hperror. php (62): checkString (Array) #1 {main} thrown in D: \ xampp \ htdocs \ phperror. php on line 82 Array ([0] => 1) */function checkString ($ y) {if (! Is_string ($ y) {throw new Exception ('not a string');} return $ y;} function printData ($ data) {echo''; print_r($data);}