【问题标题】:php mailgun error unexpected )php mailgun错误意外)
【发布时间】:2015-01-11 10:19:15
【问题描述】:

我的以下代码部分基于 Mailgun 文档。我在错误日志中得到了这个:

2014 年 11 月 14 日 04:21:52 UTC] PHP 解析错误:语法错误,意外 ')' 在 /home/[USERNAME]/public_html/m/FileName.php 第 36 行

这是我的源代码:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
date_default_timezone_set('EST');
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
require 'html2text.php';
use Mailgun\Mailgun;
# Instantiate the client.
$mgClient = new Mailgun('[KEY]');
$domain = "[DOMAIN]";
$html = $_POST["message"];
$text = convert_html_to_text($html);
$date = date('l, F jS ');
# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
    'from'    => '[EMAIL]',
    'to'      => '[EMAIL]',
    'cc'      => '[EMAIL]',
    'subject' => 'New reminder for ' . $date,
    'text'    => 'Hey, ' . "\n" . $text . "\n" . 'More text',
    'html'    => '<html><body>Hey, ' . "\n" . $html . "\n" . 'More Text.</body></html>'
), );
print '<h1>Sent successfully</h1>';
?>

对正在发生的事情有任何想法吗?第 36 行是结束数组的行。

【问题讨论】:

    标签: php syntax-error mailgun


    【解决方案1】:

    尝试替换

    ), );
    

    ));
    

    从末尾删除逗号。这里不需要逗号,因为您不再向函数传递任何参数。

    【讨论】:

      【解决方案2】:

      试试这个

      $result = $mgClient->sendMessage($domain, array(
          'from'    => '[EMAIL]',
          'to'      => '[EMAIL]',
          'cc'      => '[EMAIL]',
          'subject' => 'New reminder for ' . $date,
          'text'    => 'Hey, ' . "\n" . $text . "\n" . 'More text',
          'html'    => '<html><body>Hey, ' . "\n" . $html . "\n" . 'More Text.</body></html>'
      ));
      

      【讨论】:

        猜你喜欢
        • 2015-02-18
        • 1970-01-01
        • 2013-10-12
        • 2014-05-10
        • 1970-01-01
        • 2012-05-16
        • 1970-01-01
        • 2012-08-15
        • 2015-05-28
        相关资源
        最近更新 更多