Example usage:
<?php
//Errors will be printed on the screen with the following line
error_reporting(E_STRICT);
function change (&$var) {
$var += 10;
}
$var = 1;
change(++$var);
echo "var=$var";
change($var = 5);
echo "var=$var";
?>
More examples:
http://en.wikipedia.org/wiki/E_STRICT
E_STRICT のチェック
ひとつのスクリプトについてのみチェックしたいのであれば、 PHP コマンドラインの文法チェック機能を使用して E_STRICT エラーを抜き出すことができます。
php -d error_reporting=4095 -l script_to_check.php
大量のファイルをチェックするのなら、以下のシェルスクリプトで同様のことが可能です。
#!/bin/sh
directory=$1
shift
# チェックする拡張子を指定します
extensions="php inc"
check_file ()
{
echo -ne "Doing PHP syntax check on $1 ..."
# オプション
ERRORS=`/www/php/bin/php -d display_errors=1 -d html_errors=0 -d error_prepend_string=" " -d error_append_string=" " -d error_reporting=4095 -l $1 | grep -v "No syntax errors detected"`
if test -z "$ERRORS"; then
echo -ne "OK."
else
echo -e "Errors found!\n$ERRORS"
fi
echo
}
# loop over remaining file args
for FILE in "$@" ; do
for ext in $extensions; do
if echo $FILE | grep "\.$ext$" > /dev/null; then
if test -f $FILE; then
check_file "$FILE"
fi
fi
done
done
E_STRICT のチェック
designteam at casemumbai dot com
26-Nov-2008 03:39
26-Nov-2008 03:39
