PHP Parse Error on `for` loop
<p>I'm probably just doing something stupid here, but I can't see the cause of the error.  I'm getting a Parse error on a for loop in a pagination function I'm writing in PHP; heres the full error. </p>

<pre><code>PHP Parse error:  parse error, expecting `')'' in /Users/danielsgroves/Sites/Gouland/search.php on line 95
</code></pre>

<p>And the full function that the error is occurring in is as follows:</p>

<pre><code>private function pagination($scope, $keyword)
{
    $pages = 15;

    $pagination = '&lt;ul&gt;';
    for ($i = 0; $i &lt; $pages; i++) {
        $pagination .= "&lt;li&gt;&lt;a id=\"a$i\" class=\"na\" href=\"?q=$keyword&amp;scope=$scope&amp;page=$i\"&gt;$i&lt;/a&gt;&lt;/li&gt;";
    }
    $pagination .= '&lt;/ul&gt;';

    return $pagination;
}
</code></pre>

<p>As you may have already established from what I said the line 95 mentioned on the error is <code>for ($i = 0; $</code> etc.  The full class file is below. I've included the commenting just incase it helps. </p>

<pre><code>Class BingSearch
{
private $APPID      = "SOME API KEY";

private $keyword;
private $scope;
private $page;
private $count;
private $offset;

private $response;
private $results;

/**
 * Set the object up with required information to perform the search. Once 
 * the object is setup the getResults() method should be called to display
 * the results where required. 
 * @param (String) $keyword = The search string
 * @param (String) $scope = The scope of the search; web, ticket, image, 
 * video, news
 * @param (Int) $page = The required results page.
 * @public
 */
public function __construct($keyword, $scope, $page)
{
    $this-&gt;keyword  = urlencode($keyword);
    $this-&gt;scope    = $scope;
    $this-&gt;page     = $page;
}

/**
 * Runs the necessary internal methods to fetch and display the required 
 * results.  Required information should be provided into the constructor 
 * on object creation.  This function will not return any information,
 * but 'echo' is straight out onto the page. Each returned result will
 * be placed inside it's own HTML5 &lt;article&gt; tag.  Simply call this 
 * method from the location in your templates of where you would like
 * the search results to be placed.  
 * @public
 */
public function getResults()
{
    $this-&gt;fetchFeed();
    $this-&gt;generateWebResults();
}

/**
 * Fetches the JSON feed from the Google bing API.  Uses private class
 * variables for the required information. 
 * @private
 */
private function fetchFeed()
{
    $request        = "http://api.search.live.net/json.aspx?Appid=$this-&gt;APPID&amp;query=$this-&gt;keyword&amp;sources=$this-&gt;scope&amp;$this-&gt;count&amp;$this-&gt;offset";
    $this-&gt;response = file_get_contents($request);
    $this-&gt;results = json_decode($this-&gt;response);
}

/**
 * Formats the returned JSON feed by adapting it for HTML. Each result is 
 * placed within an &lt;article&gt; tag.  The title is an &lt;h3&gt; which also links
 * to the actual result. &lt;span class="cached"&gt; is the cache link and 
 * the description is placed within a &lt;p&gt;.  Finally, &lt;span class="fullLink"&gt;
 * contains the URL for the content, which is also linked.  
 * @private
 */
private function generateWebResults()
{
    if($this-&gt;results-&gt;SearchResponse-&gt;Web-&gt;Total != 0) {   

        foreach($this-&gt;results-&gt;SearchResponse-&gt;Web-&gt;Results as $value) {

            if (!isset($value-&gt;Description))
                $value-&gt;Description = '';

            echo "&lt;article&gt;";
            echo "&lt;h3&gt;&lt;a href=\"$value-&gt;Url\" title=\"Go to $value-&gt;Title\"&gt;$value-&gt;Title&lt;/a&gt;&lt;/h3&gt;";
            echo "&lt;span class=\"cached\"&gt;&lt;a href=\"$value-&gt;CacheUrl\" title=\"View Cached Version\"&gt;Cached&lt;/a&gt;&lt;/span&gt;";
            echo "&lt;p&gt;" . strip_tags($value-&gt;Description) . "&lt;/p&gt;";
            echo "&lt;span class=\"fullLink\"&gt;&lt;a href=\"$value-&gt;Url\" title=\"Go to $value-&gt;Title\"&gt;$value-&gt;Url&lt;/a&gt;&lt;/span&gt;";
            echo "&lt;/article&gt;";

        }

    }
}

private function pagination($scope, $keyword)
{
    $pages = 15;

    $pagination = '&lt;ul&gt;';
    for ($i = 0; $i &lt; $pages; i++) {
        $pagination .= "&lt;li&gt;&lt;a id=\"a$i\" class=\"na\" href=\"?q=$keyword&amp;scope=$scope&amp;page=$i\"&gt;$i&lt;/a&gt;&lt;/li&gt;";
    }
    $pagination .= '&lt;/ul&gt;';

    return $pagination;
}
}
</code></pre>

<p>To use the function this is the PHP that is run. </p>

<pre><code>require 'search.php';
$search = new BingSearch($query, $source, $query);
$search-&gt;getResults();
</code></pre>

<p>Does anyone fancy pointing me in the right direction, it's probably something really small that I've just missed after looking at it for too long.  </p>

<p>Thanks,</p>

<p>Dan.</p>
