반응형
1. array 출력하는 함수

function dump_array($array) {

    if (is_array($array)) {

        $size = count($array);

        $string = "";

        if ($size) {

            $count = 0;

            $string .= "{";

            foreach ($array as $var => $value) {

                $string .= $var . " = " . $value;

                if ($count++ < ($size-1)) {

                    $string .= ", ";

                }

            }

            $string .= " }";

        }

        return $string;

    } else {

        return $array;

    }

}


2. 오류 처리 방법

function errorHandler ($errno, $errstr, $errfile, $errline) {

echo "<br/><table bgcolor=\"#cccccc\"><tr><td>

      <p><strong>ERROR:</strong> " . $errstr . "</p>

      <p>Please try again, or contact us and tell us

      that the error occurred in line " . $errline . " of

      file " . $errfile . "</p>";

if (($errno == E_USERERROR) || ($errno == E_ERROR)) {

echo "<p>This error was fatal, program ending</p>

      </td></tr></table>";

exit;

}

echo "</td></tr></table>";

}

set_error_handler('errorHandler');

trigger_error('Trigger function called', E_USER_NOTICE); 







 
반응형
Posted by seungkyua@gmail.com
,