I would like to be able to display in the application if it's running latest PHP version by comparing return of phpversion() with the latest from http://php.net/ChangeLog-5.php - can I check this in a better way than parsing the mentioned URL's HTML?
Updated Answer
When visiting http://www.php.net/releases, I noticed that on the right panel, it says:
Want a PHP serialized list of the PHP releases?
Add
?serializeto the url
Only want PHP 5 releases?&version=5
The last 3?&max=3Want a JSON list of the PHP releases?
Add
?jsonto the url
Only want PHP 5 releases?&version=5
The last 3?&max=3
So whether you'd rather use a PHP serialized version or JSON, you might use http://www.php.net/releases?serialize or http://www.php.net/releases?json
If you want to only see Version 5.x.x, you could use:
http://www.php.net/releases?json&version=5 (If you'd like to use JSON, otherwise replace json with serialize)
Original Answer (Critical, see Nannes comment)
Parsing the HTML structure is of course a bad idea, since the structure of the tags could change when a new homepage of php.net is introduced.
While searching for a solution, I came across this Atom feed: http://php.net/releases/feed.php
Since this is a Atom feed, the strucutre will not change, as it is defined by a standard 1]. You can then use PHP's default XML functions 2] to parse feed > entry:first-child > php:version (CSS-Syntax for demonstration purpose. :first-child is the first child selector, > the direct child selector) and then use PHP's version_compare 3].
More information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With