Since yesterday, this question has been bothering me.
Php wrote the page, has been garbled. Oddly, there is a folder of files is not garbled, open to show normal after.
Moving the files to another location, or copying the contents to another file,
Implement a simple template engine yourself: Aspects of PHP logic and the separation of the page
Template class:
Page to call:
assign ("title", $title);
$tpl->assign ("content", $content);
$tpl->display ("mysmarty.html");
? >
There is such a need, according to the user's IP address, locate the user's city.
This article records the article, has no logic. Friends with such needs can be used directly for copying. Directly on the code, do not need to repeat.
Results
1. What is a template engine
Two parts more concerned
1.1 is the GUI (view, interface)--html CSS javascripte
1.2 is the business logic (PHP code)--php MYSQL
The template engine is a project developed using PHP
2.Smarty
2.1 Installation
1. Extract,
String, integer, floating-point number, logic, array, object, NULL.
1, the demarcation sign PHP demarcation symbol to determine the start and end of the PHP script, four different styles to embed PHP code in the HTML code ① standard: ②: >③js and Vbs:
The day before yesterday to find a lot of access to the file name method (as long as the filename, do not suffix), mainly the way to intercept the string, if the file name contains Chinese, good to write some of their own functions, to ensure that
Read the online many log4php articles, mostly v0.8, v0.9, are very old, according to the above is always wrong, now out to V2.0, OK, I will tell you how to configure this version.
1, first on the
", $con);
Echo $con;
}else{echo "file does not exist";
//close file, must fclose ($FP);
The second way to read the file, automatically closes the file//direct access to the file content//To determine whether the file exists
preparatory work
Download php:http://www.php.net/downloads.php download PHP Related: vc_redist.x64 (do not download this word, launch will report to find DLL), more than 10 m not big
Modify PHP configuration
Find Php.ini-development file, modify to
There are some flaws, but the lambda definition of the natural number of church can be realized
Class Lambda {private $f;
Private $args;
Private $count;
Public function __construct ($f, $args = []) {if ($f instanceof Lambda)
-20319, ' ai ' = >-20317, ' an ' =>-20304, ' ang ' =>-20295, ' ao ' =>-20292, ' ba ' =>-20283, ' Bai ' =>-20265, ' ban ' =>-20257, ' Bang ' =>-20242, ' bao ' =>-20230, ' bei ' =>-20051, ' Ben ' =>-20036, ' Beng ' =>-20032, ' bi ' =>-20026, ' bian ' >
PHP object is a few similarities and differences with java,c++,
1.PHP classes can duplicate constructor __construct and destructors, which are similar to C + +, and default to parameterless constructs and destructors if not written
Replication
The so-called master-slave separation is written from the primary database, from the server to read data, whether a main one from or a master from, the server is instantaneous synchronization, the program end only need to process is written in the
init.smarty.php
template_dir=root. " /templates/";
$tpl->compile_dir=root. " /templates_c/";
The configuration file location
$tpl->config_dir=root. " /configs/";
$TPL->caching=0;//Cache file location, the development phase does not open,
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