Jump to content

Unexpedted end of file

Go to solution Solved by Ch0cu3r,

Recommended Posts

I am trying to put an rss feed from my Flickr account into my website I have got thus far with my class:-


 // Flickr Class
class flickr

	// Properties
	var $feed;

	// Construct Flickr
	function __construct($feed)
		$this->feed = $feed;

	// Parse Method
	function parse()
		$rss = simplexml_load_file($this->feed);
		$photodisp = array();
			foreach ($rss->channel->item as $item)
				$link = (string) $item->link; // Link to this photo
				$title = (string) $item->title; // Title of this photo
				$media = $item->children('http://search.yahoo.com/mrss/');
				$thumb = $media->thumbnail->attributes();
				$url = (string) $thumb['url']; // URL of the thumbnail
				$width = (string) $thumb['width']; // Width of the thumbnail
				$height = (string) $thumb['height']; // Height of the thumbnail
				$photodisp[] = <<<________________EOD
		return $photodisp;

	// Display Method
	function display($numrows=6,$head="Photos on Flickr")
		$photodisp = $this->parse();
		$i = 0;
		$thumbs = <<<____________EOD
			while ( $i < $numrows )
				$thumbs .= $photodisp[$i];
		$trim = str_replace('http://api.flickr.com/services/feeds/photos_public.gne?id=', '',$this->feed);
		$user = str_replace('〈=en-us&format=rss_200','',$trim);
		$thumbs .= <<<____________EOD
		View All Photos on Flickr
		return $thumbs;

//End of Class

?> // <- Line 66

and it gives me "Parse error: syntax error, unexpected end of file in C:\wamp\www\image-a-nation\test4_class.php on line 66". I thought it might be an unclosed brace/bracket or something like that, but no amount of checking finds anything - would appreciate a fresh pair of eyes...

Edited by foucquet
Link to comment
Share on other sites

  • Solution

The problem is to do with the closing heredoc delimiter (  ____________EOD;  ) used on lines 34, 47 and 57. No characters (including spaces) should proceed the closing delimiter. The closing delimiter for a heredoc statement should start at the very first character of the next line.


But there is no need for the use of heredoc in your situation, it is mainly used for large complex strings not for one liners.


Lines 32 - 34 should be    $photodisp[] = "$title";

Lines 45 - 47 should be    $thumbs = "head";   

Lines 55 - 57 should be    $thumbs .= "View All Photos on Flickr";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.