欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

獲取PHP警告錯誤信息的解決方法_PHP教程

編輯Tag賺U幣

推薦:php cli 小技巧
很簡單,特別方便php做一些cli應(yīng)用的調(diào)試,需要的朋友可以參考下

代碼如下所示:
復(fù)制代碼 代碼如下:m.dounai2.com

<?php
/**
* 更新非法字符、發(fā)送錯誤信息
*
* @author
* @copyright 2009-06-10
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_error_handler('displayErrorHandler');//自定義錯誤
//調(diào)試信息
echo "time:".date("Y-m-d H:i:s")."\n";
//數(shù)據(jù)配置
//公共函數(shù)
function displayErrorHandler($error, $error_string, $filename, $line, $symbols)
{
$error_no_arr = array(1=>'ERROR', 2=>'WARNING', 4=>'PARSE', 8=>'NOTICE', 16=>'CORE_ERROR', 32=>'CORE_WARNING', 64=>'COMPILE_ERROR', 128=>'COMPILE_WARNING', 256=>'USER_ERROR', 512=>'USER_WARNING', 1024=>'USER_NOTICE', 2047=>'ALL', 2048=>'STRICT');
$msg = s if(in_array($error,array(1,2,4))){
echo $msg; echo "\n";//調(diào)試顯示
//發(fā)送信息
if($error==1||$error==2) {
sendBankMsg($error_string); //發(fā)送簡訊
if(strpos($error_string, '
xml_parse(): Bytes:')!==FALSE){
writeFiltefile($error_string);
}
}
}
}
function hex2bin($hexdata) {
$bindata = '';
for($i=0; $i < strlen($hexdata); $i += 2) {
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
}
return $bindata;
}
function writeFiltefile($error_string)
{
if(strpos($error_string, 'xml_parse(): Bytes:')===FALSE||strpos($error_string, ' 0x')===FALSE){
return;
}
//寫入文件
$filename = 'filtetext.php';
include($filename);
$error_string = str_replace('xml_parse(): Bytes:', '', $error_string);
$error_string = str_replace(' 0x','', $error_string);
$error_text = hex2bin($error_string);
$filtetextArr[] = $error_text;
$tempArr = array_unique($filtetextArr);//去除重復(fù)
$result = implode("','",$tempArr);
$result = "<?php\n\$filtetextArr = array('".$result."');\n?>";
fileWrite($filename, $result, 'w');
}
function sendBankMsg($msg)
{
$timestamp = time();
$params = "msg=".$msg
."&posttime=".$timestamp;
$length = strlen($params);
//創(chuàng)建socket連接
$domain = "www.admin.com"; //socket域名
$actionPath = "/action/bank/bankmsg.php"; //文件路徑
$fp = fsockopen($domain,80);
//構(gòu)造post請求的頭
if($fp){
$header = "POST ".$actionPath." HTTP/1.1\r\n";
$header .= "Host:".$domain."\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".$length."\r\n";
$header .= "Connection: Close\r\n\r\n";
//添加post的字符串
$header .= $params."\r\n";
//發(fā)送post的數(shù)據(jù)
fputs($fp,$header);
while (!feof($fp)) {
$line = fgets($fp,1024); //去除請求包的頭只顯示頁面的返回數(shù)據(jù)
if ($inheader && ($line == "\n" || $line == "\r\n")) {
echo $line;
}
}
fclose($fp);
}
}
function fileWrite($fFileName, $fContent, $fTag = 'w') {
ignore_user_abort (TRUE);
$fp = fopen($fFileName, $fTag);
if (flock($fp, LOCK_EX)) {
fwrite($fp, $fContent);
flock($fp, LOCK_UN);
}
fclose($fp);
ignore_user_abort (FALSE);
return;
}
?>

分享:php中用加號與用array_merge合并數(shù)組的區(qū)別深入分析
本篇文章是對php中用加號與用array_merge合并數(shù)組的區(qū)別進行了詳細的分析介紹,需要的朋友參考下

來源:模板無憂//所屬分類:PHP教程/更新時間:2013-06-04
相關(guān)PHP教程