PHP 5.4

So what?!
Always prefer the english manual!
Backward Incompatible Changes
Safe mode is no longer
      supported
Magic quotes has been removed.
The register_globals and
register_long_arrays ini directives
       have been removed.
Call-time pass by reference has
        been removed.
The break and continue statements
     no longer accept variable
            arguments.
In the date and time extension, the
timezone can no longer be set using
    the TZ environment variable.
Non-numeric string offsets - e.g.
$a['foo'] where $a is a string - now
 return false on isset() and true on
empty(), and produce a warning if
        you try to use them.
Converting an array to a string will
 now generate an E_NOTICE level
              error
The default character set is now
 UTF-8, instead of ISO-8859-1
New Reserved Keywords
• trait
• callable
• insteadof
New Features
Traits
Short array syntax
• $a = [1, 2, 3, 4];
• $a = ['one' => 1, 'two' => 2, 'three' => 3, 4];
Function array dereferencing
• foo()[0]
Closures now support $this
<?= is now always available,
regardless of the short_open_tag ini
               option.
Class member access on instantiation
          has been added
• (new Foo)->bar()
Session Upload Progress
• Session extension can now track the upload
  progress of files.
• ini settings
  – session.upload_progress.enabled = true
  – session.upload_progress.cleanup = true
  – session.upload_progress.prefix = "upload_progress_ "
  – session.upload_progress.name =
    "PHP_SESSION_UPLOAD_PROGRESS "
  – session.upload_progress.freq = "1%"
  – session.upload_progress.min-freq = 1
Built-in web server in CLI mode
• php -S localhost:8000 -t foo/

• C:UsersfuhrDownloadsphp-5.4.0-Win32-
  VC9-x86>.php -c php.ini-development -S
  localhost:8181 -t
  Usersfuhrworkspacephp54src
Changed Functions
Stack Frame Limit
• array debug_backtrace ([ int $options =
  DEBUG_BACKTRACE_PROVIDE_OBJECT [, int
  $limit = 0 ]] )
• void debug_print_backtrace ([ int $options = 0
  [, int $limit = 0 ]] )
New Classes and Interfaces
JsonSerializable
SessionHandler &
SessionHandlerInterface
CallbackFilterIterator &
RecursiveCallbackFilterIterator
New Methods
SPL
•   RegexIterator::getRegex()
•   SplObjectStorage::getHash()
•   DirectoryIterator::getExtension()
•   SplDoublyLinkedList::serialize()
•   SplDoublyLinkedList::unserialize()
•   SplFileInfo::getExtension()
•   SplFileObject::fputcsv()
•   SplQueue::serialize()
•   SplQueue::unserialize()
•   SplStack::serialize()
•   SplStack::unserialize()
•   SplTempFileObject::fputcsv()
Further Reading
• http://www.php.net/manual/en/migration54.
  php
• http://css.dzone.com/articles/writing-clean-
  code-php-54
• http://net.tutsplus.com/tutorials/php/php-5-
  4-is-here-what-you-must-know/

PHP 5.4 - So what?!