What’s new in PHP 5.4

Quinlan
Share on Facebook0Tweet about this on Twitter0

On October 18th, 2012, PHP 5.4.8 was released by the PHP development team. If you’re uncomfortable (or bored) with the ChangeLog, here’s a breakdown of some of the more notable changes:

New array syntax

Use brackets instead (array() is still supported).

[sourcecode language=”php”]
// old
$quinlan = array(’employees’ => ‘cool’, ‘environment’ => ‘fun’);

// new short array syntax
$quinlan = [’employees’ => ‘cool’, ‘environment’ => ‘fun’];
[/sourcecode]

Deprecated features

• The register_globals feature has been removed. This setting would register $_POST, $_GET, $_COOKIE, and $_SERVER variables as global variables (with no code required).

• The magic_quotes feature has been removed. This setting would add a backslash to all ' single-quote and " double-quote characters automatically. The addslashes() function does the exact same thing.

• The safe_mode feature has been removed. It was designed to prevent hackers from being able to use PHP scripts to execute commands at the operating system level and intended to be a security method for web applications running on shared hosting accounts. When enabled, there are a slew of PHP functions that are disabled (much to the chagrin of shared-hosting customers).

• The allow_call_time_pass_reference feature has been removed. This setting would issue a warning when arguments were passed by reference at function call time. According to PHP: “Passing arguments by reference at function call time was deprecated for code-cleanliness reasons”.

• You no longer have the ability to pass in variables to break and continue:

[sourcecode language=”php”]
break $some_var;
continue $some_other_var;
[/sourcecode]

This argument instructed continue how many levels of enclosing loops it should skip to the end of and break how many nested enclosing structures are to be broken out of. Read more on PHP control structures.

Lastly; a recurring theme with each release, PHP has improved performance, reduced memory consumption, and has addressed numerous bug fixes.

Talk to your System Administrator and upgrade today! Good luck and happy coding!

For questions or concerns contact me on twitter @mike_petruniak

Leave a Reply

Your email address will not be published. Required fields are marked *