Q:

php Fatal error: Cannot redeclare class AppMailCore in /appmail.core.php on line 10

I'm getting this error when I run the script 
php Fatal error:  Cannot redeclare class AppMailCore in /appmail.core.php on line 10

I need to make loop that will also use some variables from a class file . The code from main.php looks like this :

   $iesc = 1;
 while($iesc less than 5)
{
include('includes/appmail.core.php');
---

I used "less than " in the code above 'cause I don't know to unescape "<" symbold within the pre markup .
I understand that I'm  not allowed to re-delcare the class but I don't know how to make the class variables run through the loop .
appmail.core.php looks like this 

require_once('appmail.config.php');
require_once('helpers'.DIRECTORY_SEPARATOR.'appmail.rest.php');

class AppMailCore
{
  var $AppMailRest;
  var $api_key;
  var $url;

  /**
   * Initialises AppMailCore. Optionally provide runtime api key and url.
   */
  function AppMailCore($api_key = APPMAIL_API_KEY, $url = APPMAIL_URL) {
    $this->url = $url;
    $this->api_key = $api_key;
    $this->AppMailRest = new AppMailRest($this->url);
  }

  /**
   * Asynchronously sends an email using Google App Engine
   *
   * Params are fairly self explanatory. However, note that the "from" address must be a registered email with
   * your Google App Engine account.
   */
  function send($to, $from, $subject, $plain, $html) {
    $api_key = $this->api_key;
    $status = $this->AppMailRest->post('send', compact('api_key','to','from','subject','plain','html'));
    return $status;
  }
}

the appmail.config.php loooks like this 

  $app1DB = new mysqli("localhost", "root", "", "ast");
  $app1RSP = $app1DB->query("SELECT app_id FROM Application WHERE emails_sent fetch_assoc();
    $app_id = $app1Object['app_id'];

define('APPMAIL_API_KEY', 'JLQ7P5SnTPq7AJvLnUysJmXSeXTrhgaJ');
define('APPMAIL_URL', "http://$app_id.appspot.com/");

   $app1RSP->free();
   $app1DB->close();

Basically I need to get variable APPMAIL_URL/$app_id in the class on each loop run.

A:

Why aren't you doing the include before the loop ?
Another tip: use include_once ?
Third tip: include directly appmail.config.php if you need a constant from it, not appmail.core.php ?
EDIT

Basically I need to get variable
  APPMAIL_URL/$app_id in the class on
  each loop run.

If its value is supposed to change through the script execution (as I just saw), then you shouldn't define it as a constant.

