PHP5 and PHP4 compatibility issues

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View has a very interesting PHP script which
gathers RSS data from various feeds and prints them in an HTML table.
He calls this a lifestream.

Anyways, unfortunately, my knowledge of PHP is rather limited - I'd
rather work with a stylesheet. It turns out that my local machine has
PHP5, and the script works flawlessly. However, Bluehost, my hosting
provider, has PHP 4.4.4. As a result, I'm getting a lot of exceptions
thrown around. I think I figured out my way around the
getElementsByTagName(), which should be get_elements_by_tagname() in
PHP4, but I'm still getting heavy exceptions. I also googled and found
that the date_default_timezone_set() function isn't supported in PHP4

I'd appreciate it greatly if anyone could point out where the
incompatibilities are - even if there's a better way of doing this RSS
gathering, I'd just like to see anyway for educational purposes.

My PHP source is the following (I've left out the HTML surrounding


$feeds = array(
"feed1" => "http://...",
"feed2" => "http://...",
"feed3" => "http://...",
"feed4" => "http://..."

$details = array("title","link");

$list = array();

$rss = new DOMDocument();

foreach ($feeds as $name => $feed) {

    $rss -> load($feed);

    $items = $rss -> getElementsByTagName("item");

    foreach ($items as $item) {

        if ($item -> getElementsByTagName("pubDate") -> item(0)) {
            $date = $item -> getElementsByTagName("pubDate") ->
item(0) -> nodeValue;
        } else {
            $date = $item -> getElementsByTagName("date") -> item(0) -
Quoted text here. Click to load it
        $date = strtotime(substr($date,0,25));

        $list[$date]["name"] = $name;

        foreach ($details as $detail) {

            $list[$date][$detail] = $item ->
getElementsByTagName($detail) -> item(0) -> nodeValue;



$day = "";

foreach ($list as $timestamp => $item) {

    $this_day = date("F jS",$timestamp);

    if ($day != $this_day) {

        echo "</tbody>\n";
        echo "<thead>\n";
        echo "<tr>\n";
        echo "<th colspan=\"3\">";
        echo $this_day;
        echo "</th>\n";
        echo "</tr>\n";
        echo "</thead>\n";
        echo "<tbody>\n";

        $day = $this_day;


    echo "<tr class=\"vevent_";
    echo $item["name"];
    echo "\">\n";
    echo "<th>";
    echo "<abbr class=\"dtstart\" title=\"";
    echo date("c",$timestamp);
    echo "\">";
    echo date("g:ia",$timestamp);
    echo "</abbr>";
    echo "</th>\n";
    echo "<td>";
    echo "<a class=\"url_summary\" href=\"";
    echo $item["link"];
    echo "\">";
    echo $item["title"];
    echo "</a>";
    echo "</td>\n";
    echo "<td class=\"icon\">";
    echo "<img src=\"images/";
    echo $item["name"];
    echo ".gif\" alt=\"";
    echo $item["name"];
    echo "\" />";
    echo "</td>\n";
    echo "</tr>\n";



Many thanks,


Re: PHP5 and PHP4 compatibility issues

Quoted text here. Click to load it

Dear Adri,

$rss->getElementsByTagName("item"); uses the a methode of the
DOMDocument class. Thus is most likely NOT your problem with a change
from PHP5 to PHP4.

I assume that the class itself is written for PHP5. Or your two PHP
setups just use different settings.

Good luck

online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
m2m server software gmbh

Re: PHP5 and PHP4 compatibility issues

eltower wrote:

Quoted text here. Click to load it

Google: MagpieRSS.

Toby A Inkster BSc (Hons) ARCS
Contact Me ~
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Site Timeline