小巧的php文档生成类
在项目开发中发现对php的文档缺少管理,别人写了一个,功能不多
<?php
/**
* 类名: doc
*
描述: 文档生成类
* 其他: 可以对目录进行过滤,设置好源目录后,请用绝对路径指定生成目录,模式可调,模式
*
1为常规类型,即以 斜线**开头,以*斜线 结束
* 2为扩展类型,凡是 斜线*开头以*斜线 结束的部分都将成为文档的一部分
*/
class doc
{
var $docdirname;
var $docdir;
/**
*
函数名称: doc()
* 函数功能: 构造
* 输入参数: none
* 函数返回值: 返回值说明
*
其它说明: 2004-10-13
*/
function doc()
{
$this->docdirname
= "doc/";
}
/**
* 函数名称:
createDoc($root,$newdir,$mode="1",$filter=null)
* 函数功能: 创建文档
*
输入参数: $root -------------- 源目录
$newdir ----------- 目标目录
$mode
------------- 模式,1为普通,2为扩展
$filter ------------ 过滤目录
* 函数返回值:
返回值说明
* 其它说明: 2004-10-13
*/
function
createDoc($root,$newdir,$mode="1",$filter=null)
{
$getarr =
$this->loopDir($root,$filter);
$i = 0;
$this->createFrame($newdir);
foreach($getarr as $key=>$val)
{
if($this->getPhpFiles($val))
{
$content = $this->getContent($val);
$content =
$this->getDoc($content,$mode);
$filepath =
$this->setFilepath($val,$root,$newdir);
$filedir =
$this->getFileDir($filepath);
$this->mkdirs($filedir);
$this->setDoc($filepath,$content);
$data[$i]['url'] = "$filepath";
$data[$i]['name'] = "$val";
$i++;
}
}
if(!empty($data))
{
$this->createMenu($newdir,$data);
$this->redirect($this->docdir);
}
}
/**
*
函数名称: redirect($path)
* 函数功能: 转向
* 输入参数: $path ----------------
转向路径
* 函数返回值: 返回值说明
* 其它说明: 2004-10-13
*/
function
redirect($path)
{
echo "<a href=".$path."
target='_blank'>生成文档成功,点击此处查看</a>";
}
/**
*
函数名称: loopDir($root,$filter=null)
* 函数功能: 遍历目录
* 输入参
相关文档:
1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
<?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......
PHP创建文件(夹)以及目录操作
一、目录操作
首先是从目录读取的函数,opendir(),readdir(),closedir(),使用的时候是先打开文件句柄,而后迭代列出:
<?php
$base_dir="filelist/";
$fso=opendir($base_dir);
echo $base_dir."<hr/>";
whil ......
<?php
require_once ('unit_tester.php');
require_once ('reporter.php');
require_once ('../config.php');
require_once ('../source\modules\user\user_api.func.php');
require_once ('../source/base_model.class.php');
Class registertest extends UnitTestCase{
public function testAssertEqual(){
$b ......
代码如下,
// 建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Can't start Word!");
// 显示目前正在使用的Word的版本号
echo "Loading Word, v. {$word->Version}
";
exit;
?>
有时候你会得到一个错误,
PHP Fatal error: Uncaught except ......
<?php
if($_POST['str'])
{
header('Content-type: application/doc');
header('Content-Disposition: attachment; filename="downloaded.doc"');
echo iconv("UTF-8","GB2312",$_POST['str']);
}
?>
<a href="javascript:void(0)" onclick="downword()">下载</a>
<div id="word" style="dis ......