Sample Call

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password

define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once ('../userAuth.php');

try {
  $mySforceConnection = new SforcePartnerClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $query = 'SELECT NumberOfEmployees from Lead where NumberOfEmployees != null order by NumberOfEmployees';
  $options = new QueryOptions(200);
  $mySforceConnection->setQueryOptions($options);
  $response = $mySforceConnection->query($query);
  $queryResult = new QueryResult($response);
  !$done = false;

  echo "Size of records:  ".$queryResult->size."\n";

  if ($queryResult->size > 0) {
    while (!$done) {
      foreach ($queryResult->records as $record) {
        echo $record->fields->NumberOfEmployees."\r\n";
      }
      if ($queryResult->done != true) {
        echo "***** Get Next Chunk *****\n";
        try {
          $response = $mySforceConnection->queryMore($queryResult->queryLocator);
          $queryResult = new QueryResult($response);
        } catch (Exception $e) {
          print_r($mySforceConnection->getLastRequest());
          echo $e->faultstring;
        }
      } else {
        $done = true;
      }
    }
  }

} catch (Exception $e) {
  print_r($mySforceConnection->getLastRequest());
  echo $e->faultstring;
}
?>

Sample Output

Size of records:  2
1
9000