【发布时间】:2015-07-28 05:25:30
【问题描述】:
我有一个带有命名空间的类,它还需要许多其他类。主类是
<?php
/**
* Deals with PDF document level aspects.
*/
namespace Aspose\Cloud\Pdf;
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Product;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Event\SplitPageEvent;
use Aspose\Cloud\Exception\AsposeCloudException as Exception;
use Aspose\Cloud\Storage\Folder;
class Document
{
public $fileName = '';
public function __construct($fileName='')
{
$this->fileName = $fileName;
}
/**
* Gets the page count of the specified PDF document.
*
* @return integer
*/
public function getFormFields()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return $json->Fields->List;
}
}
我在 index.php 中这样使用它
<?
ini_set('display_errors', '1');
use Aspose\Cloud\Pdf;
$document=new Document;
echo $document->GetFormFields();
//or like this
echo Document::GetFormFields();
//also tried this
echo pdf::GetFormFields();
?>
错误
Fatal error: Class 'Document' not found in /var/www/pdfparser/asposetry/index.php on line 5
文档类路径为Aspose/Cloud/Pdf/Document.php
尝试一下
如果我使用包含在 index.php include(Aspose/Cloud/Pdf/Document.php) 中但随后进一步的命名空间会产生错误。很难用include 更改每个use 命名空间。有朋友能告诉我解决方法吗??
谢谢。
【问题讨论】:
标签: php oop namespaces