Convenient and practical php generation static page class (non-Smarty) 1th/2 page _php Tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
/*********************/
/* */
/* version:5.2.5 */
/* author:liqiangwork#sohu.com */
/* qq:570937581 */
/* */
/*********************/
-----------------------------generate a static class-------------------------------
Class makehtml{
Public $MbUrl, $OUTURL, $AllHtml, $SouChar, $ObjChar; Variable
Public $row; Cursor
Public $Shuzusou, $Shuzuobj; Array of strings replaced
-----------------------initialization-------------------------
function __construct () {//initialization
$this->mburl= "";
$this->outurl= "";
$this->allhtml= "";
$this->sql= "";
$this->souchar= "";
$this->objchar= "";
}
-----------------------------automatically replaced by fields---------------------------
function Autoreplace () {
------------------automatically gets the string to replace-------------------
$tlen =count ($row);
$shuzu 1=array ();
$shuzu 2=array ();
if ($row) {
$i = 0;
foreach ($row as $key = = $value) {
$shuzu 2[i]= "<=\$". $key. " \$> ";
$shuzu 1[i]= $value;
$i + +;
}
$this->replacehtml (SHUZU2,SHUZU1);
}
------------------automatically gets the string to replace-------------------
}
-----------------------------is automatically replaced by field------------------------
-----------------------------Bulk Replace Array--------------------------
function replacehtml ($Shuzusou, $Shuzuobj) {//Bulk replace array
if (count ($Shuzusou)!=count ($Shuzuobj)) {
Exit ("Replace array mismatch");
}
if ($this->allhtml== "") {
Exit ("No content to replace");
}
for ($i =0; $i $this->allhtml=str_replace ($Shuzusou [$i], $Shuzuobj [$i], $this->allhtml);
Print ("
". $Shuzusou (i)." = ". $Shuzuobj (i)."
")
}
}
-----------------------------Bulk Replace array complete--------------------------
-----------------------------Read Files---------------------------------
function Readfile () {
$file =fopen ($this->mburl, "R");
$fsize =filesize ($this->mburl);
$this->allhtml=fread ($file, $fsize);
Fclose ($file);
}
-----------------------------Read File Completion------------------------------
-----------------------------Save the file---------------------------------
function SaveFile () {
$file =fopen ($this->outurl, "w");
Fwrite ($file, $this->allhtml);
Fclose ($file);
}
-----------------------------Save file Complete------------------------------
}
------------------------------generate a static class completion-------------------------------

Related examples:

http://www.bkjia.com/PHPjc/319586.html www.bkjia.com true http://www.bkjia.com/PHPjc/319586.html techarticle Copy the code as follows:/*********************//* */* version:5.2.5 *//* author:liqiangwork#sohu.com *//* qq:570937581 * / /* */ /*********************/ //------------...

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.