What's the difference between 5 and 4?

liunx

Guest
Title explains itself.See the manual (<!-- m --><a class="postlink" href="http://php.net/manual/en/migration5.php">http://php.net/manual/en/migration5.php</a><!-- m -->).1?1 difference?Difference of 1 (5 - 4 = 1).Haha, hilarious. But really I don't notice many differences between the two versions.Did you read the link to the manual entry on the subject? Its the OOP type stuff where most of the changes are, along with a few other little extras here and there.... along with a few other little extras here and there ...

Three other interesting features/functions are (personal opinion)

* PDO extension (<!-- m --><a class="postlink" href="http://www.php.net/pdo">http://www.php.net/pdo</a><!-- m -->) (PHP Data Objects). PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data

* SimpleXML (<!-- m --><a class="postlink" href="http://www.php.net/simplexml">http://www.php.net/simplexml</a><!-- m -->). Makes it really easy to work with XML.

* SQLite database (<!-- m --><a class="postlink" href="http://www.php.net/sqlite">http://www.php.net/sqlite</a><!-- m -->). Flatfile database with a lot of features and it's fast too.Basically, flip through the manual and note the bits that are marked as having been introduced in PHP 5 (or later).

A more raw listing would be to look at the PHP5 Changelog (<!-- m --><a class="postlink" href="http://www.php.net/ChangeLog-5.php">http://www.php.net/ChangeLog-5.php</a><!-- m -->).One important difference is that PHP4 is deprecated and won't be supported after a while, whereas PHP5 is not and will continue to receive updates after the developers abandon PHP4.

No new project should be developed on, or support PHP4.

MarkOne important difference is that PHP4 is deprecated and won't be supported after a while, whereas PHP5 is not and will continue to receive updates after the developers abandon PHP4.

No new project should be developed on, or support PHP4.

Mark
PHP 4 is not depreciated unless you can link to an official Zend source that says otherwise.

It's true the eventually PHP 4 will no longer be supported but I'd say that won't happen for at least another 5 years and quite possibly longer. Remember also that it's open source so even is Zend stops support the community can continue it.

I agree with the notion of moving to PHP 5 but usually it's more a question of having to stay with PHP 4 due to legacy apps. Furthermore, I think if I was still mostly focused on PHP 4 apps then I might be tempted to just wait until PHP 6 is released and leap frog over PHP 5.Furthermore, I think if I was still mostly focused on PHP 4 apps then I might be tempted to just wait until PHP 6 is released and leap frog over PHP 5.Why bother? If you're going to wait then why not wait until PHP 7?PHP 4 is not depreciated unless you can link to an official Zend source that says otherwise.


What I meant by PHP4 being deprecated was, PHP5 has superceded it and is better in every respect, notwithstanding Zend's position on it.


I agree with the notion of moving to PHP 5 but usually it's more a question of having to stay with PHP 4 due to legacy apps.


But new apps SHOULD use PHP5. I can't see any case of starting a new project aimed (even optionally) at PHP4.

Legacy apps should be migrated to PHP5 at the earliest opportunity.

None of my new apps have any compatibility with PHP4 and I don't intend to write any more which do.


Furthermore, I think if I was still mostly focused on PHP 4 apps then I might be tempted to just wait until PHP 6 is released and leap frog over PHP 5.

Why? PHP6 will (mostly) contain a superset of PHP5's functions, why not start using them now, after all, they are very useful.

MarkPHP 5 is significantly faster, I did some benchmarks.


None of my new apps have any compatibility with PHP4 and I don't intend to write any more which do.


Same with me.Some of the things I have seen that are different so far are:


visibility keywords were added (ex. public, private, protected)
the class constructor is now __construct() instead of the Class_name()
you can have class type hints when writing a function
the static keyword is introduced
you can use abstract classes
you can throw exceptions
 
Back
Top