PHP Doku:: Checking for E_STRICT - migration51.errorcheck.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchAppendicesMigrating from PHP 5.0.x to PHP 5.1.xChecking for E_STRICT

Ein Service von Reinhard Neidl - Webprogrammierung.

Migrating from PHP 5.0.x to PHP 5.1.x

<<Changes in database support

Migrating from PHP 4 to PHP 5.0.x>>

Checking for E_STRICT

If you only have a single script to check, you can pick up E_STRICT errors using PHP's commandline lint facility:

php -d error_reporting=4095 -l script_to_check.php

For larger projects, the shell script below will achieve the same task:

#!/bin/sh

directory=$1

shift

# These extensions are checked
extensions="php inc"

check_file ()
{
  echo -ne "Doing PHP syntax check on $1 ..."

  # Options:
  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

Ein BenutzerBeitrag:
- Beiträge aktualisieren...
designteam at casemumbai dot com
26.11.2008 7:39
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



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)