<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
		<id>https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Php%2Ferror%E3%83%A1%E3%83%BC%E3%83%AB</id>
		<title>Php/errorメール - 変更履歴</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Php%2Ferror%E3%83%A1%E3%83%BC%E3%83%AB"/>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Php/error%E3%83%A1%E3%83%BC%E3%83%AB&amp;action=history"/>
		<updated>2026-04-18T18:19:31Z</updated>
		<subtitle>このウィキのこのページに関する変更履歴</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Php/error%E3%83%A1%E3%83%BC%E3%83%AB&amp;diff=4593&amp;oldid=prev</id>
		<title>Admin: /* メール本文にはこのように表示される */</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Php/error%E3%83%A1%E3%83%BC%E3%83%AB&amp;diff=4593&amp;oldid=prev"/>
				<updated>2017-07-20T15:42:54Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;メール本文にはこのように表示される&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←前の版&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2017年7月20日 (木) 15:42時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行97:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行97:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==メール本文にはこのように表示される==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==メール本文にはこのように表示される==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; [ERROR:] [Msg:Call to undefined function testa()] [File:/var/www/zend/example/application/batch/testbatch.php] [Line:8]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; [ERROR:] [Msg:Call to undefined function testa()] [File:/var/www/zend/example/application/batch/testbatch.php] [Line:8]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==メモリ限界エラーが検知できないので以下のようにmemory size~を追加する==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; if ($error['type'] === E_ERROR || $error['type'] === E_USER_ERROR || $error['type'] === E_USER_NOTICE&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  || strpos($error['message'], 'Allowed memory size of') !== false) {&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; // メモリ限界に達したエラーでもメールできるように&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; ini_set(&amp;quot;memory_limit&amp;quot;, &amp;quot;8096M&amp;quot;);&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; 〜略 メール送信コード〜&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==メール処理はzendを利用==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==メール処理はzendを利用==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[php/zend_framework/zend_mail]] [ｼｮｰﾄｶｯﾄ]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[php/zend_framework/zend_mail]] [ｼｮｰﾄｶｯﾄ]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Php/error%E3%83%A1%E3%83%BC%E3%83%AB&amp;diff=306&amp;oldid=prev</id>
		<title>127.0.0.1: ページの作成:「==fatalエラーをキャッチしてメールで送信== *application/batch/testbatch.php  require_once APPLICATION_PATH . '/models/ErrorMailModel.php';  register_shutdo...」</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Php/error%E3%83%A1%E3%83%BC%E3%83%AB&amp;diff=306&amp;oldid=prev"/>
				<updated>2015-05-19T18:10:08Z</updated>
		
		<summary type="html">&lt;p&gt;ページの作成:「==fatalエラーをキャッチしてメールで送信== *application/batch/testbatch.php  require_once APPLICATION_PATH . &amp;#039;/models/ErrorMailModel.php&amp;#039;;  register_shutdo...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==fatalエラーをキャッチしてメールで送信==&lt;br /&gt;
*application/batch/testbatch.php&lt;br /&gt;
 require_once APPLICATION_PATH . '/models/ErrorMailModel.php';&lt;br /&gt;
 register_shutdown_function(array('ErrorMailModel', 'fatalHandler'));&lt;br /&gt;
 set_error_handler(array('ErrorMailModel', &amp;quot;errorHandler&amp;quot;));&lt;br /&gt;
 $a = $b;&lt;br /&gt;
 testa();&lt;br /&gt;
&lt;br /&gt;
*application/models/ErrorMailModel.php&lt;br /&gt;
 /**&lt;br /&gt;
  * エラーメールハンドラクラス&lt;br /&gt;
  * @ex&lt;br /&gt;
 require_once APPLICATION_PATH . '/models/ErrorMailModel.php';&lt;br /&gt;
 register_shutdown_function(array('ErrorMailModel', 'fatalHandler'));&lt;br /&gt;
 set_error_handler(array('ErrorMailModel', &amp;quot;errorHandler&amp;quot;));&lt;br /&gt;
 $a = $b;&lt;br /&gt;
 testa();&lt;br /&gt;
 */&lt;br /&gt;
 class ErrorMailModel&lt;br /&gt;
 {&lt;br /&gt;
  private static function _getErrorCodeByNo($errno)&lt;br /&gt;
  {&lt;br /&gt;
    $errcode = &amp;quot;&amp;quot;;&lt;br /&gt;
    switch ($errno){&lt;br /&gt;
    case E_ERROR: // 1 //&lt;br /&gt;
      $errcode = 'E_ERROR'; break;&lt;br /&gt;
    case E_WARNING: // 2 //&lt;br /&gt;
      $errcode = 'E_WARNING'; break;&lt;br /&gt;
    case E_PARSE: // 4 //&lt;br /&gt;
      $errcode = 'E_PARSE'; break;&lt;br /&gt;
    case E_NOTICE: // 8 //&lt;br /&gt;
      $errcode = 'E_NOTICE'; break;&lt;br /&gt;
    case E_CORE_ERROR: // 16 //&lt;br /&gt;
      $errcode = 'E_CORE_ERROR'; break;&lt;br /&gt;
    case E_CORE_WARNING: // 32 //&lt;br /&gt;
      $errcode = 'E_CORE_WARNING'; break;&lt;br /&gt;
    case E_COMPILE_ERROR: // 64 //&lt;br /&gt;
      $errcode = 'E_COMPILE_ERROR'; break;&lt;br /&gt;
    case E_CORE_WARNING: // 128 //&lt;br /&gt;
      $errcode = 'E_COMPILE_WARNING'; break;&lt;br /&gt;
    case E_USER_ERROR: // 256 //&lt;br /&gt;
      $errcode = 'E_USER_ERROR'; break;&lt;br /&gt;
    case E_USER_WARNING: // 512 //&lt;br /&gt;
      $errcode = 'E_USER_WARNING'; break;&lt;br /&gt;
    case E_USER_NOTICE: // 1024 //&lt;br /&gt;
      $errcode = 'E_USER_NOTICE'; break;&lt;br /&gt;
    case E_STRICT: // 2048 //&lt;br /&gt;
      $errcode = 'E_STRICT'; break;&lt;br /&gt;
    case E_RECOVERABLE_ERROR: // 4096 //&lt;br /&gt;
      $errcode = 'E_RECOVERABLE_ERROR'; break;&lt;br /&gt;
    case E_DEPRECATED: // 8192 //&lt;br /&gt;
      $errcode = 'E_DEPRECATED'; break;&lt;br /&gt;
    case E_USER_DEPRECATED: // 16384 //&lt;br /&gt;
      $errcode = 'E_USER_DEPRECATED'; break;&lt;br /&gt;
    }&lt;br /&gt;
    return $errcode;&lt;br /&gt;
  }&lt;br /&gt;
  // fatalエラー検知&lt;br /&gt;
  public static function fatalHandler() {&lt;br /&gt;
    $error = error_get_last();&lt;br /&gt;
    $errcode = self::_getErrorCodeByNo($errno);&lt;br /&gt;
    if ($error['type'] === E_ERROR || $error['type'] === E_USER_ERROR || $error['type'] === E_USER_NOTICE) {&lt;br /&gt;
      $linemsg = sprintf(&amp;quot;[ERROR:%s] [Msg:%s] [File:%s] [Line:%s]\n&amp;quot;,&lt;br /&gt;
        $errcode, $error['message'], $error['file'], $error['line']);&lt;br /&gt;
      $str = &amp;quot;&amp;quot;;&lt;br /&gt;
      foreach ($_SERVER as $key =&amp;gt; $value) {&lt;br /&gt;
        if ($key) {&lt;br /&gt;
          if (preg_match(&amp;quot;/^(SCRIPT_NAME)$/&amp;quot;, $key)) {&lt;br /&gt;
            $str .= sprintf(&amp;quot;%s:%s\n&amp;quot;, $key, $value);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      $text = $linemsg. $str;&lt;br /&gt;
      // メール処理をここに入れる&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // warningなど検知&lt;br /&gt;
  public static function errorHandler($errno, $errstr, $errfile, $errline)&lt;br /&gt;
  {&lt;br /&gt;
    $errcode = self::_getErrorCodeByNo($errno);&lt;br /&gt;
    $linemsg = sprintf(&amp;quot;[%s] [Msg:%s] [File:%s] [Line:%s]\n&amp;quot;, $errcode, $errstr, $errfile, $errline);&lt;br /&gt;
    $headerlog = &amp;quot;&amp;quot;;&lt;br /&gt;
    $backtraces = debug_backtrace();&lt;br /&gt;
    foreach ($backtraces as $key =&amp;gt; $trace) {&lt;br /&gt;
      if (array_key_exists('file', $trace)&lt;br /&gt;
        &amp;amp;&amp;amp; array_key_exists('line', $trace)&lt;br /&gt;
        &amp;amp;&amp;amp; array_key_exists('class', $trace)) {&lt;br /&gt;
      $headerlog .= sprintf(&amp;quot;#%d %s(%d): %s::%s\n&amp;quot;, $key, $trace['file'], $trace['line'], $trace['class'], $trace['function']);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    $text = $linemsg. $headerlog;&lt;br /&gt;
    // warningなどは無視&lt;br /&gt;
    // メール処理をここに入れる&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==メール本文にはこのように表示される==&lt;br /&gt;
 [ERROR:] [Msg:Call to undefined function testa()] [File:/var/www/zend/example/application/batch/testbatch.php] [Line:8]&lt;br /&gt;
&lt;br /&gt;
==メール処理はzendを利用==&lt;br /&gt;
[[php/zend_framework/zend_mail]] [ｼｮｰﾄｶｯﾄ]&lt;/div&gt;</summary>
		<author><name>127.0.0.1</name></author>	</entry>

	</feed>