我有 PHP 5.4.21
我正在使用可以在浏览器中正常工作的 Twilio API,但在命令行模式下,我收到以下错误:
<b>Parse error</b>: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>sms/Services/Twilio.php</b> on line <b>36</b>
指定文件的第 36 行是以下类的一部分,请参阅我的注释,其中我指定了第 36 行。
根据一些初始反馈请求,我在第 36 行之前和之后添加了所有代码行以显示这些行的上下文。
<?php
function Services_Twilio_autoload($className) {
if (substr($className, 0, 15) != 'Services_Twilio') {
return false;
}
$file = str_replace('_', '/', $className);
$file = str_replace('Services/', '', $file);
return include dirname(__FILE__) . "/$file.php";
}
spl_autoload_register('Services_Twilio_autoload');
/**
* Create a client to talk to the Twilio API.
*
*
* :param string $sid: Your Account SID
* :param string $token: Your Auth token from
* twilio.com/user/account
* :param string $version: API version to use
* :param $_http: A HTTP client for making requests.
* :type $_http: :php:class:`Services_Twilio_Http`
* :param int $retryAttempts:
* Number of times to retry failed requests. Currently only idempotent
* requests (GET's and DELETE's) are retried .
*/
class Services_Twilio extends Services_Twilio_Resource
{
/* this is Line 36... */
const USER_AGENT = 'twilio-php/3.12.0';
protected $http;
protected $retryAttempts;
protected $last_response;
protected $version;
protected $versions = array('2008-08-01', '2010-04-01');
public function __construct(
$sid,
$token,
$version = null,
Services_Twilio_TinyHttp $_http = null,
$retryAttempts = 1
) {
$_http = new Services_Twilio_TinyHttp(
"https://api.twilio.com",
array("curlopts" => array(
CURLOPT_USERAGENT => self::USER_AGENT,
CURLOPT_HTTPHEADER => array('Accept-Charset: utf-8'),
CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem',
))
);
}
}
?>