是否可以在同一个文件夹中使用同一名称空间下的多个类?我想做这样的事情:
<?php
namespace MyNamespace\Helpers\Exceptions
use Exception;
class CustomException1 extends Exception{}
class CustomException2 extends Exception{}
class CustomException3 extends Exception{}
Run Code Online (Sandbox Code Playgroud)
避免为每个自定义异常类使用一个文件.问题是,当我尝试在另一个类中使用其中一个自定义异常时,
use MyNamespace\Helpers\Exceptions\CustomException1;
Run Code Online (Sandbox Code Playgroud)
找不到CustomException1类.有任何想法吗?
我正在尝试使用Google PHP Api客户端从G +页面获取所有活动:
$service = new \Google_Service_Plus($this->client);
$activities = $service->activities->listActivities($data['page_id'], 'public');
Run Code Online (Sandbox Code Playgroud)
结果是一个Google_Service_Plus_Activity对象数组.问题是我想访问其中一个活动的内容来搜索字符串,但这是在["modelData":protected]=> array(1)as 下["content"]=> string(int) "my_string".是否有可能访问内容?
var_dump($activity):
object(Google_Service_Plus_Activity)#268 (28) { ["internal_gapi_mappings":protected]=> array(0) { } ["accessType":protected]=> string(23) "Google_Service_Plus_Acl" ["accessDataType":protected]=> string(0) "" ["actorType":protected]=> string(33) "Google_Service_Plus_ActivityActor" ["actorDataType":protected]=> string(0) "" ["address"]=> NULL ["annotation"]=> NULL ["crosspostSource"]=> NULL ["etag"]=> string(57) ""RqKWnRU4WW46-6W3rWhLR9iFZQM/t4CM2-QFWMd8gXogVxXGqNUhGSA"" ["geocode"]=> NULL ["id"]=> string(35) "z133dxyyhuaqf5tqd04cebxrtuykyfc5vi0" ["kind"]=> string(13) "plus#activity" ["locationType":protected]=> string(25) "Google_Service_Plus_Place" ["locationDataType":protected]=> string(0) "" ["objectType":protected]=> string(34) "Google_Service_Plus_ActivityObject" ["objectDataType":protected]=> string(0) "" ["placeId"]=> NULL ["placeName"]=> NULL ["providerType":protected]=> …Run Code Online (Sandbox Code Playgroud)