douhua1760 2011-03-29 13:33
浏览 59
已采纳

php致命错误:无法在第10行的/appmail.core.php中重新声明类AppMailCore

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.

  • 写回答

1条回答 默认 最新

  • dsour68888 2011-03-29 13:50
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。