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);

  $createFields = array (
  'FirstName' => 'George',
  'LastName' => 'Smith',
  'Phone' => '510-555-5555',
  'BirthDate' => '1927-01-25',
  'Email' => 'test@example.com'
  );

  $sObject = new stdclass();
  $sObject->fields = $createFields;
  $sObject->type = 'Contact';

  echo "Creating New Contact\n";
  $createResponse = $mySforceConnection->create(array($sObject));
  print_r($createResponse);

  $sObject->fields['FirstName'] = 'Bill';
  $sObject->fields['LastName'] = 'Clinton';

  echo "Upserting Contact (existing)\n";
  $upsertResponse = $mySforceConnection->upsert("Email", array ($sObject));
  print_r($upsertResponse);

  $sObject->fields['FirstName'] = 'John';
  $sObject->fields['LastName'] = 'Smith';
  $sObject->fields['Email'] = 'testNew@example.com';

  echo "Upserting Contact (new)\n";
  $upsertResponse = $mySforceConnection->upsert("Email", array ($sObject));
  print_r($upsertResponse);

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

Sample Output

Creating New Contact
stdClass Object
(
    [id] => 0035000000o1agAAAQ
    [success] => 1
)
Upserting Contact (existing)
stdClass Object
(
    [created] => 
    [id] => 0035000000o1agAAAQ
    [success] => 1
)
Upserting Contact (new)
stdClass Object
(
    [created] => 1
    [id] => 0035000000o1ag6AAA
    [success] => 1
)