国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊 Php Ctemplate引擎開發(fā)相關(guān)內(nèi)容

Php Ctemplate引擎開發(fā)相關(guān)內(nèi)容

Jun 13, 2016 pm 12:02 PM
php content develop engine Related Introduction this

1.簡介

也許你對Php Ctemplate不了,解甚看到這個名詞,只知道它的前半部分是一種編程語言。沒有關(guān)系讓我來給大家介紹一下這個基于php語言的標(biāo)簽?zāi)0嬉妫ㄕ堅试S我這樣去翻譯這套web開發(fā)解決方案,盡管我可能翻譯的不準(zhǔn)確)。

先簡短說一下他的歷史。了解Php Ctemplate先要知道Ctempalte;Ctempalte全稱是Google Ctemplate。它是一種用c++語言、簡單但是效率非常高的網(wǎng)頁模版引擎。讓我們來看一段代碼,聰明的你立刻就知道它怎么用了(來自官方Demo)

那么C++輸出便是:
Hello John Smith
You Have just won (這里是執(zhí)行random%100000 隨機(jī)數(shù))
Well ,(這里是執(zhí)行random%100000 的隨機(jī)數(shù)再 * 0.83),after taxes
好吧,總結(jié)一下 就是把c++源碼中的Template對象加載 tpl(我們可以稱它為模版)文件之后,再填充TemplateDictionary中的對應(yīng)的值,最后輸出。聽起來很拗口是吧,簡單點(diǎn)把后端標(biāo)簽對應(yīng)值填充到tpl的{{標(biāo)簽}}中。
詳細(xì)的請參見http://google-ctemplate.googlecode.com/svn/trunk/doc/index.html
那么PHP ctemplate呢?大家都知道PHP擴(kuò)展吧,玩過PHP的朋友都知道gd,exif,mysql,mysqli這些擴(kuò)展吧。對,就是php.ini 文件里“extension=”那里的dll。我總結(jié)PHP ctemplate就是用PHP擴(kuò)展接口的格式,包裝了Google Ctemplate,讓PHP具有Google Ctemplate的功能。再通俗點(diǎn)體現(xiàn)在代碼上就是:tpl文件不變,只是把c++ 文件變成了php文件。至于它的用法我想我在這里就不多介紹了,他和Google Ctempalte 一樣。
詳見http://code.google.com/p/php-ctemplate/
2.WIN32下可以嗎
也許你會很快意識到這種模版引擎,符合我們常見的MVC吧。沒錯,就是這樣。但是很遺憾,PHP Ctemplate只能在Freebsd系統(tǒng)中運(yùn)行,win32環(huán)境中的php,我至今沒有在網(wǎng)上發(fā)現(xiàn)對應(yīng)的PHP ctemplate dll,我也咨詢過PHP ctemplate的作者,他好像不太愿意在win32環(huán)境中編譯這些代碼;我曾經(jīng)和我開發(fā)c++的朋友“阿呆”試著編譯,我們找了php源碼+ Ctemplate源碼+PHP ctemplate源碼編譯出了win32下的PHP ctemplate擴(kuò)展,但是很奇怪,每次php啟動加載PHP ctemplate時,php引擎就會出現(xiàn)異常,PHP ctemplate不能正常加載。

如果成功加載php ctemplate則會在phpinfo 中顯示:

????? 我也看了下PHP ctemplate的源碼好像是基于Zend編寫的。因為本人對c++和php都不是很精通,實在也沒有能力去重新編寫這套擴(kuò)展,所以只能想了個折中的辦法:把Ctemplate用ATL COM 包裝起來,模擬PHP ctemplate的函數(shù)和方法。

3.我的嘗試

????? 之所以這么曲折,是因為用這套框架后,根本沒有辦法調(diào)試PHP代碼,我試過在freebsd的環(huán)境中安裝xdebug,好吧,勉強(qiáng)能進(jìn)行遠(yuǎn)程調(diào)試??墒莊reebsd是沒有圖形界面的,哎,無奈下安裝了gnome,只能暫時這樣了。出于好奇和不服氣,我把Ctemplate用ATL COM 包裝起來,模擬PHP ctemplate的函數(shù)和方法,但是只完成了一半。在這里要特別感謝“阿呆”同志,沒有他我也根本寫不出c++的ATL。下面是ATL COM里面的方法(只完成了一部分)。

?

我包裝的ATL COM 功能我包裝在了core.php 中。

????? 如果大家有興趣可以找我要源碼繼續(xù)完善,因為它是COM的所以ASP也可以使用,我會把dll提供下載。如果大蝦們成在win32下成功編譯使用PHP ctemplate,那我更求之不得。
下載COM文件 phpctempalteCOM

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why We Comment: A PHP Guide Why We Comment: A PHP Guide Jul 15, 2025 am 02:48 AM

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

How Do You Handle File Operations (Reading/Writing) in PHP? How Do You Handle File Operations (Reading/Writing) in PHP? Jul 16, 2025 am 03:48 AM

TohandlefileoperationsinPHP,useappropriatefunctionsandmodes.1.Toreadafile,usefile_get_contents()forsmallfilesorfgets()inaloopforline-by-lineprocessing.2.Towritetoafile,usefile_put_contents()forsimplewritesorappendingwiththeFILE_APPENDflag,orfwrite()w

How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

Your First PHP Script: A Practical Introduction Your First PHP Script: A Practical Introduction Jul 16, 2025 am 03:42 AM

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

What is PHP and What is it Used For? What is PHP and What is it Used For? Jul 16, 2025 am 03:45 AM

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

PHP Syntax: The Basics PHP Syntax: The Basics Jul 15, 2025 am 02:46 AM

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

PHP 8 Installation Guide PHP 8 Installation Guide Jul 16, 2025 am 03:41 AM

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

python if else example python if else example Jul 15, 2025 am 02:55 AM

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.

See all articles