使用phpword lib保存RTF文件时遇到一些问题。
我用<section id="category-navi">
<div class="cats-menu" id="cats-menu">
<div class="container">
<div class="parent-menu">
<nav class="navbar">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
{foreach from=$cats item=cat}
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{$cat.name} <span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu">
{foreach from=$cat.categories item=subcat}
<li class="col-sm-3">
<ul>
<li class="dropdown-header">{$subcat.sc_name}</li>
{foreach from=$subcat.ccname item=childcat}
<li><a href="#">{$childcat.cc_name}</a></li>
{/foreach}
</ul>
</li>
{/foreach}
</ul>
</li>
{/foreach}
</ul>
</div><!-- /.nav-collapse -->
</nav>
</div>
</div>
</div>
</section>
打开一个RTF文件,然后使用函数write将其保存,并且该文件上有一些元数据,我不知道为什么。
这是我的代码:
IOFactory::load
当我打开被保存的新文件时,它会显示:
<?php
include_once 'vendor/phpoffice/phpword/samples/Sample_Header.php';
// Read contents
$name = 'Sample';
$source = __DIR__ . "/vendor/phpoffice/phpword/samples/resources/{$name}.rtf";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'RTF');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
include_once 'vendor/phpoffice/phpword/samples/Sample_Footer.php';
如果有人知道为什么我的文件中有一些元数据会很好。