欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

try(........){throw new Exception("xxxxxx")}........catch(){.........}用法

程序员文章站 2022-07-15 12:54:42
...

 

<?php
function ActionSend($mobile, $key='')
{
  
	 try
	 {
		 /* if (empty($key)) {
		   throw new Exception('key值不能为空');
		  }
		  if($key != 'adfasdfdasfs') {
		   throw new Exception('key值不一致');
		  }
		  echo 'oo';
		  */

		   echo 1/0;
		   echo "throw";
		   //throw new Exception ( "Method not exists!" );
	}
	 catch(Exception $e)
	{

		 print_r($e);
		  echo "xxx";
	}

}

ActionSend('15801668635','adfasdfdasfs');


?>
   输出:
Warning: Division by zero in E:\wamp\www\test\try.php on line 16
throw