我需要在文档的首页添加页脚:
require_once 'vendor\autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(array(
'orientation' => 'portrait')
);
$footer = $section->addFooter(Footer::FIRST); <- Line 49
但出现错误:
Uncaught错误:在C:\ xxxxxxxxxx:49中找不到类'Footer'
我什至尝试在软件包中要求Footer.php。尽管我在每个页面上都获得了页脚,但没有Footer :: FIRST参数,Word文档生成仍然可以正常工作。我也刚升级到版本0.17关于为什么会发生错误的任何想法?
没有完整的名称空间,PHP将无法找到正确的Footer
类。为了解决这个问题,只需声明页脚类的完整名称空间
$footer = $section->addFooter(\PhpOffice\PhpWord\Element\Footer::FIRST);