The lack of management of PHP documents found in project development, others write a, the function is not much
<?php
/**
* Class Name: Doc
* Description: Document Generation class
* Other: You can filter the directory, set the source directory, please use the absolute path to specify the build directory, mode adjustable, mode
* 1 is the normal type, that is, the beginning with a slash *, ending with a * slash
* 2 is an extended type, the part of the general slash * at the end of the * slash will become part of the document
*/
Class doc
{
var $docdirname;
var $docdir;
/**
* Function name: Doc ()
* Function Function: Construction
* Input Parameters: None
* Function return Value: Return value description
* Other Notes: 2004-10-13
*/
function doc ()
{
$this->docdirname = "doc/";
}
/**
* Function Name: Etfilepath ($filepath, $oldroot, $newroot)
* Function function: Set the path of the build file
* Input parameter: $filepath--------------source file path
$oldroot--------------Source directory path
$newroot--------------Destination directory path
* Function return Value: string
* Other Notes: 2004-10-13
*/
function SetFilePath ($filepath, $oldroot, $newroot)
{
$oldroot = Str_replace ('/', "\\/", $oldroot);
$pattern = "/". $oldroot. " (. *)/iu ";
$filepath = Preg_replace ($pattern, ' \\1 ', $filepath);
$newpath = $newroot. $this->docdirname $filepath;//echo "$newpath <br>";
$newpath = Preg_replace ('/(. *\.) (.*[^\.]. *)/I ', ' \\1htm ', $newpath);
return $newpath;
}
/**
* Function Name: Getfiledir ($path)
* Function function: Get the document Directory
* Input Parameters: $path-------------Document Path
* Function return Value: string
* Other Notes: 2004-10-13
*/
function Getfiledir ($path)
{
$getpath = Preg_replace ('/(. *) (\/.*[^\.]. *)/I ', ' \\1 ', $path);
return $getpath;
}
/**
* Function Name: Setdoc
* Function function: Write notes to the specified directory and generate pages
* Input parameters: $filepath---------------directory path
What is written $content----------------
* Function return Value: Return value description
* Other Description: Description
*/
function Setdoc ($filepath, $content)
{
$fp = fopen ($filepath, "w+");
Flock ($FP, LOCK_EX);
Fwrite ($fp, $content);
Flock ($FP, lock_un);
}
/**
* Function Name: mkdirs ($path)
* Function function: Create a table of contents
* Input parameters: $path-------------------Path
* Function return value: None
* Other Notes: 2004-10-13
*/
function Mkdirs ($path)
{
$adir = explode ('/', $path);
$dirlist = ';
$rootdir = $adir [0];
Array_shift ($adir);
foreach ($adir as $key => $val)
{
if ($val!= '. ') && $val!= ' ... ')
{
$dirlist. = "/". $val;
$dirpath = $rootdir. $dirlist;
if (!file_exists ($dirpath) &&!is_file ($dirpath))
{
mkdir ($dirpath);
chmod ($dirpath, 0777);
}
}
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.