php超小型模版類

2021-07-02 00:52:57 字數 1235 閱讀 4882

總結:

$smarty的工作流程:

1:把需要顯示的全域性變數,賦值,塞到物件內部的屬性上,乙個陣列內

2:編譯模版,把,解析成響應的phpe echo**

3:引入編譯後的php檔案

使用smarty的步驟:

1:smarty是乙個類,要使用,需先引入並例項化

2:assign賦值

3:dispaly[編譯到輸出]

smarty之辦

1:編譯模版,浪費時間

2:要把變數再重新賦值到物件屬性上,增大開銷

include('./mini.class.php');

$mini

=new mini();

$mini

->template_dir=

'./templates';

$mini

->compile_dir=

'./compile';

$content

='mao';

$mini

->assign('content',$content);

$mini

->display('03.html');

模版類:

<?php

/*模版類的第一步:

把標籤解析php輸出語句

模版檔案-》php檔案

*//*

為了目錄清晰,我們把模版和編譯後的結果,放在不同的目錄裡

用2個屬性來記錄這2個目錄

*/class

mini

public

function

display

($template)

/*string $template 模板檔名

return string

流程:把指定的模版內容讀過來,再編譯成php

*/public

function

compile

($template)

//替換模版內容

$source=str_replace('','\'];?>', $source);

// echo $source;

//再把編譯後的內容儲存成點php檔案

file_put_contents($comp,$source);

return

$comp;

}}

超小型迴圈式伺服器 原生socket程式設計

閒來無聊,寫了乙個體積很小的tcp迴圈式伺服器,方便各系統移植。特共享如下,編譯後體積約為8kb,經過7 24小時壓力測試,5個以內連線都ok。結合我之前的tcp 程式,可以做成乙個網絡卡埠資訊掃瞄日誌服務。include include include include define serv po...

Femtocell一種超小型手機基站裝置

五一期間,學習了一篇文章。隨後,又google了一下。發現了這篇文章。錄下來作為備忘。伴隨google準備競標700mhz頻譜,還有一條新聞是google投資英國femtocell 3g家庭基站裝置新興提供商ubiquisys公司。看來google對電信行業的滲透是越來越厲害,那麼為什麼google...

小型版php框架

鏈結位址 github.com cxp1539 min 簡單版php框架 單入口index.php 採用物件導向思想,基於mvc設計思想,使用觀察者,註冊器,工廠,trait特性等模式開發。使用namespace命名空間。autoloader自動載入類。debug,profiler 效能分析器 提供...