【发布时间】:2013-09-26 02:24:08
【问题描述】:
对于旧版本的 php 5.2 和更早版本,我用什么代替命名空间 使用下面的代码会给出错误解析错误:语法错误,意外的 T_STRING
<?php
namespace Aws\Tests\CloudWatch;
use Aws\CloudSearch\CloudSearchClient;
class CloudSearchClientTest extends \Guzzle\Tests\GuzzleTestCase
{
/**
* @covers Aws\CloudSearch\CloudSearchClient::factory
*/
public function testFactoryInitializesClient()
{
$client = CloudSearchClient::factory(array(
'key' => 'foo',
'secret' => 'bar',
'region' => 'us-east-1'
));
$this->assertInstanceOf('Aws\Common\Signature\SignatureV4', $this->readAttribute($client, 'signature'));
$this->assertInstanceOf('Aws\Common\Credentials\Credentials', $client->getCredentials());
$this->assertEquals('https://cloudsearch.us-east-1.amazonaws.com', $client->getBaseUrl());
}
}
【问题讨论】:
-
命名空间支持从
PHP 5 >= 5.3.0开始提供。 -
stackoverflow.com/questions/12650836/… 这个页面说 php 5.3
-
OP 显然在询问 5.2 - 在标题和问题中。
-
嗨 aav,欢迎来到 SO。
-
您可以使用
use关键字删除namespace,并且可以在使用之前手动包含类,或者可以使用autoload,换句话说,您必须重构代码但最好更新@ 987654327@.
标签: php namespaces