views:

17

answers:

1

The code below is part of an rss feed parser using WordPress's simplepie fetch_feed()...

Code is:

    if ($enclosure = $item->get_enclosure(0))
    {
    $image_thumb = $item->get_enclosure()->get_link().'screenshot.jpg';
    $image = $item->get_enclosure()->get_link().'screenshot-full.jpg';
    }
    $link = esc_url( strip_tags( $item->get_link() ) );
    $content = $item->get_content();

Upon trying to activate the theme in which this code appears, I'm getting the following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/.../functions.php on line 1341

Line 1341 is the line that starts with $image_thumb

+1  A: 

My wild guess is that this is PHP 4, which doesn't support method chaining.

Pekka
@BoltClock I'm pretty sure it will! (Can't test it though, I have no PHp 4's running any more...)
Pekka
@Pekka: OK I ran a test, you're right. I must have been in some parallel universe. +1
BoltClock
@BoltClock thanks for testing it!
Pekka
Site is on a godaddy server using their WordPress 3.0.1 installer. I would expect their default PHP install to be fairly new but I will have a check...
Scott B
@Scott B if they still use PHP 4, run away screaming. Use `phpinfo()` to find out
Pekka
How might I add try/catch or error checking on that line to catch it?
Scott B
@Scott you mean to make it run in PHP 4?
Pekka
If I hardcode those two lines, no error raised.
Scott B
@Scott well, use phpinfo() to find out for sure. Working around it is easy, just don't use chaining, store the first method's result in a temporary variable. But the much preferable solution is to use PHP 5
Pekka
@pekka, I'm not sure if they have PHP4 or not, I've asked the owner of the site to find out. But I do want to avoid the error if that's the cause or not.
Scott B
Yep, he just confirmed they use PHP 4.x and once I unchained the methods, no more error.
Scott B