本文整理匯總了PHP中PhpOffice\PhpWord\PhpWord::addTitle方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhpWord::addTitle方法的具體用法?PHP PhpWord::addTitle怎麽用?PHP PhpWord::addTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhpOffice\PhpWord\PhpWord
的用法示例。
在下文中一共展示了PhpWord::addTitle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetGetMinMaxDepth
/**
* Set/get minDepth and maxDepth
*/
public function testSetGetMinMaxDepth()
{
$titles = array('Heading 1' => 1, 'Heading 2' => 2, 'Heading 3' => 3, 'Heading 4' => 4);
$phpWord = new PhpWord();
foreach ($titles as $text => $depth) {
$phpWord->addTitle(new Title(htmlspecialchars($text, ENT_COMPAT, 'UTF-8'), $depth));
}
$toc = new TOC();
$toc->setPhpWord($phpWord);
$this->assertEquals(1, $toc->getMinDepth());
$this->assertEquals(9, $toc->getMaxDepth());
$toc->setMinDepth(2);
$toc->setMaxDepth(3);
$toc->getTitles();
$this->assertEquals(2, $toc->getMinDepth());
$this->assertEquals(3, $toc->getMaxDepth());
}