------解决方案--------------------
session_start();
//session_register('SafeCode');//这个函数已列于废止,使用时会有警告
$type = 'gif';
$width= 60;
$height= 20;
header("Content-type: image/".$type);
srand((double)microtime()*1000000);
$_SESSION['SafeCode'] = $randval = randStr(4,"");
if($type!='gif'&&function_exists('imagecreatetruecolor')){