<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: tail functionality in PHP</title>
	<atom:link href="http://tekkie.flashbit.net/php/tail-functionality-in-php/feed" rel="self" type="application/rss+xml" />
	<link>http://tekkie.flashbit.net/php/tail-functionality-in-php</link>
	<description>Flash technology blog</description>
	<lastBuildDate>Sun, 29 Jan 2012 21:27:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Peeter tomberg</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-1627</link>
		<dc:creator>Peeter tomberg</dc:creator>
		<pubDate>Tue, 01 Feb 2011 08:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-1627</guid>
		<description>I&#039;ve written a PHP Tail class using parts of this code. You can view the source here: http://code.google.com/p/php-tail/</description>
		<content:encoded><![CDATA[<p>I&#8217;ve written a PHP Tail class using parts of this code. You can view the source here: <a href="http://code.google.com/p/php-tail/" rel="nofollow">http://code.google.com/p/php-tail/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcello Nuccio</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-1549</link>
		<dc:creator>Marcello Nuccio</dc:creator>
		<pubDate>Tue, 12 Oct 2010 08:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-1549</guid>
		<description>fgets() does not read long lines.
The following version does workaround it:

function read_file($filename, $lines_to_read) {
  $text = &#039;&#039;;
  $pos = -1;
  $handle = fopen($filename, &#039;r&#039;);

  while ($lines_to_read &gt; 0) {
    --$pos;

    if(fseek($handle, $pos, SEEK_END) !== 0) {
      rewind($handle);
      $lines_to_read = 0;
    } elseif (fgetc($handle) === &quot;\n&quot;) {
      --$lines_to_read;
    }

    $block_size = (-$pos) % 8192;
    if ($block_size === 0 &#124;&#124; $lines_to_read === 0) {
      $text = fread($handle, ($block_size === 0 ? 8192 : $block_size)) . $text;
    }
  }

  fclose($handle);
  return $text;
}

echo read_file(TEXT_FILE, LINES_COUNT);</description>
		<content:encoded><![CDATA[<p>fgets() does not read long lines.<br />
The following version does workaround it:</p>
<p>function read_file($filename, $lines_to_read) {<br />
  $text = &#8221;;<br />
  $pos = -1;<br />
  $handle = fopen($filename, &#8216;r&#8217;);</p>
<p>  while ($lines_to_read &gt; 0) {<br />
    &#8211;$pos;</p>
<p>    if(fseek($handle, $pos, SEEK_END) !== 0) {<br />
      rewind($handle);<br />
      $lines_to_read = 0;<br />
    } elseif (fgetc($handle) === &#8220;\n&#8221;) {<br />
      &#8211;$lines_to_read;<br />
    }</p>
<p>    $block_size = (-$pos) % 8192;<br />
    if ($block_size === 0 || $lines_to_read === 0) {<br />
      $text = fread($handle, ($block_size === 0 ? 8192 : $block_size)) . $text;<br />
    }<br />
  }</p>
<p>  fclose($handle);<br />
  return $text;<br />
}</p>
<p>echo read_file(TEXT_FILE, LINES_COUNT);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: littlebearz</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-1469</link>
		<dc:creator>littlebearz</dc:creator>
		<pubDate>Wed, 25 Aug 2010 00:27:47 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-1469</guid>
		<description>wow, thanks, I was just thinking how I would open the last 10 lines of my 150Mb log file without putting all of them into a buffer and swapping lines :P</description>
		<content:encoded><![CDATA[<p>wow, thanks, I was just thinking how I would open the last 10 lines of my 150Mb log file without putting all of them into a buffer and swapping lines <img src='http://tekkie.flashbit.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-898</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sat, 30 Jan 2010 17:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-898</guid>
		<description>Nice code, just what I was looking for, thx.</description>
		<content:encoded><![CDATA[<p>Nice code, just what I was looking for, thx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ain Tohvri</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-864</link>
		<dc:creator>Ain Tohvri</dc:creator>
		<pubDate>Wed, 16 Dec 2009 00:24:29 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-864</guid>
		<description>It&#039;s a splendid idea indeed! Shouldn&#039;t be too hard to do either. 

&lt;a href=&quot;http://tekkie.flashbit.net/feed&quot; rel=&quot;nofollow&quot;&gt;Subscribe to the RSS&lt;/a&gt;, I&#039;ll make sure to publish it once I have a spare hour.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a splendid idea indeed! Shouldn&#8217;t be too hard to do either. </p>
<p><a href="http://tekkie.flashbit.net/feed" rel="nofollow">Subscribe to the RSS</a>, I&#8217;ll make sure to publish it once I have a spare hour.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adi</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-862</link>
		<dc:creator>Adi</dc:creator>
		<pubDate>Mon, 14 Dec 2009 18:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-862</guid>
		<description>Extremely useful in for the small project I work on. However, if you could update it to use Ajax for example to constantly update the info without reloading the page would be magic. I have searched this on the web for a few hours and tried a few scripts but nothing really works.
Maybe I&#039;ll start from this script to make the update myself..... although I am not an programmer.

Thanks,</description>
		<content:encoded><![CDATA[<p>Extremely useful in for the small project I work on. However, if you could update it to use Ajax for example to constantly update the info without reloading the page would be magic. I have searched this on the web for a few hours and tried a few scripts but nothing really works.<br />
Maybe I&#8217;ll start from this script to make the update myself&#8230;.. although I am not an programmer.</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thesaur</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-816</link>
		<dc:creator>thesaur</dc:creator>
		<pubDate>Sun, 11 Oct 2009 20:17:58 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-816</guid>
		<description>Thanks. Quite useful. :)</description>
		<content:encoded><![CDATA[<p>Thanks. Quite useful. <img src='http://tekkie.flashbit.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ain Tohvri</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-432</link>
		<dc:creator>Ain Tohvri</dc:creator>
		<pubDate>Thu, 20 Nov 2008 00:18:12 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-432</guid>
		<description>Absolutely. You are welcome to modify as &lt;a href=&quot;#comment-369&quot; rel=&quot;nofollow&quot;&gt;Fjor&lt;/a&gt; has already quite rightly done it.</description>
		<content:encoded><![CDATA[<p>Absolutely. You are welcome to modify as <a href="#comment-369" rel="nofollow">Fjor</a> has already quite rightly done it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: louis w</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-431</link>
		<dc:creator>louis w</dc:creator>
		<pubDate>Tue, 18 Nov 2008 16:09:05 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-431</guid>
		<description>You may want to check if the file exists before you try to read it.</description>
		<content:encoded><![CDATA[<p>You may want to check if the file exists before you try to read it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fjor</title>
		<link>http://tekkie.flashbit.net/php/tail-functionality-in-php/comment-page-1#comment-369</link>
		<dc:creator>Fjor</dc:creator>
		<pubDate>Thu, 30 Oct 2008 16:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://tekkie.flashbit.net/?p=155#comment-369</guid>
		<description>Thank you very much. I modified slightly the code for letting the user change the number of lines using a GET variable.</description>
		<content:encoded><![CDATA[<p>Thank you very much. I modified slightly the code for letting the user change the number of lines using a GET variable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

