0

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

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Scott B
  • 38,833
  • 65
  • 160
  • 266

2 Answers2

3

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

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • @BoltClock I'm pretty sure it will! (Can't test it though, I have no PHp 4's running any more...) – Pekka Oct 21 '10 at 17:35
  • @Pekka: OK I ran a test, you're right. I must have been in some parallel universe. +1 – BoltClock Oct 21 '10 at 17:39
  • 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 Oct 21 '10 at 17:43
  • @Scott B if they still use PHP 4, run away screaming. Use `phpinfo()` to find out – Pekka Oct 21 '10 at 17:44
  • How might I add try/catch or error checking on that line to catch it? – Scott B Oct 21 '10 at 17:46
  • @Scott you mean to make it run in PHP 4? – Pekka Oct 21 '10 at 17:47
  • If I hardcode those two lines, no error raised. &image_thumb ="some hardcoded value"; – Scott B Oct 21 '10 at 17:48
  • @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 Oct 21 '10 at 17:49
  • @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 Oct 21 '10 at 17:50
  • Yep, he just confirmed they use PHP 4.x and once I unchained the methods, no more error. – Scott B Oct 21 '10 at 18:03
1

Yes Its PHP 4 it doesn't support multi method access in single

Fahad Baig
  • 11
  • 4