The PHP framework I developed using 13 lines of code
Jul 09, 2016 am 09:10 AMThe PHP framework I developed with only 13 lines of code. If you don’t understand the framework and don’t know what the framework does for you, you can download this framework and take a look,
In addition, if you want to develop your own framework, you can also extend the ideas of this framework.
Source code download address: http://download.csdn.net/detail/sibang/6197315
Code:
<span style="color: #008080;"> 1</span> <span style="color: #000000;">PHP </span><span style="color: #008080;"> 2</span> <span style="color: #008000;">/*</span><span style="color: #008000;">* </span><span style="color: #008080;"> 3</span> <span style="color: #008000;"> PHP極簡(jiǎn)框架 </span><span style="color: #008080;"> 4</span> <span style="color: #008000;"> 交流: </span><span style="color: #008080;"> 5</span> <span style="color: #008000;"> QQ群: 223494678 </span><span style="color: #008080;"> 6</span> <span style="color: #008000;"> http://7di.net </span><span style="color: #008080;"> 7</span> <span style="color: #008000;"> 用法 </span><span style="color: #008080;"> 8</span> <span style="color: #008000;"> http://URL </span><span style="color: #008080;"> 9</span> <span style="color: #008000;"> http://URL/hello </span><span style="color: #008080;">10</span> <span style="color: #008000;"> http://URL/seven.php?w=hello </span><span style="color: #008080;">11</span> <span style="color: #008000;">/*</span><span style="color: #008000;">*/</span> <span style="color: #008080;">12</span> <span style="color: #008080;">13</span> <span style="color: #008080;">Header</span>('Content-type: text/html; charset=UTF-8'<span style="color: #000000;">); </span><span style="color: #008080;">14</span> <span style="color: #800080;">$w</span>=<span style="color: #0000ff;">isSet</span>(<span style="color: #800080;">$_REQUEST</span>['w']) ? <span style="color: #008080;">AddsLashes</span>(<span style="color: #800080;">$_REQUEST</span>['w']) : ''<span style="color: #000000;">; </span><span style="color: #008080;">15</span> <span style="color: #800080;">$w</span>=(<span style="color: #008080;">Trim</span>(<span style="color: #800080;">$w</span>)=='') ? 'index' : <span style="color: #800080;">$w</span><span style="color: #000000;">; </span><span style="color: #008080;">16</span> <span style="color: #008080;">17</span> <span style="color: #0000ff;">IF</span>(!<span style="color: #008080;">is_callable</span>(<span style="color: #800080;">$w</span><span style="color: #000000;">)) { </span><span style="color: #008080;">18</span> <span style="color: #0000ff;">Exit</span>('Error:'.<span style="color: #ff00ff;">__LINE__</span>.',參數(shù)錯(cuò)誤!'<span style="color: #000000;">); </span><span style="color: #008080;">19</span> <span style="color: #000000;">} </span><span style="color: #008080;">20</span> <span style="color: #800080;">$w</span><span style="color: #000000;">(); </span><span style="color: #008080;">21</span> <span style="color: #008080;">22</span> <span style="color: #0000ff;">Function</span><span style="color: #000000;"> hello(){ </span><span style="color: #008080;">23</span> <span style="color: #0000ff;">Echo</span> 'Hello World!'<span style="color: #000000;">; </span><span style="color: #008080;">24</span> <span style="color: #000000;">} </span><span style="color: #008080;">25</span> <span style="color: #008080;">26</span> <span style="color: #0000ff;">Function</span><span style="color: #000000;"> index(){ </span><span style="color: #008080;">27</span> <span style="color: #0000ff;">Echo</span> '此框架由Seven編寫,來自QQ群:223494678'<span style="color: #000000;">; </span><span style="color: #008080;">28</span> }
Contents of .htaccess
Below is the comment:
Header('Content-type: text/html; charset=UTF-8'); //定義編碼 $w=isSet($_REQUEST['w']) ? AddsLashes($_REQUEST['w']) : ''; //獲取參數(shù)w的值,w來自于rewrite規(guī)則文件.htaccess $w=(Trim($w)=='') ? 'index' : $w; //如果參數(shù)w的值為空,則訪問默認(rèn)的index方法 IF(!is_callable($w)) { //如果$w所屬的function不存在 Exit('Error:'.__LINE__.',參數(shù)錯(cuò)誤!'); //拋出錯(cuò)誤 } $w(); //調(diào)用$w名稱對(duì)應(yīng)的function,例如:http://URL/hello會(huì)調(diào)用hello()這個(gè)function //自定義方法(可自由擴(kuò)展) Function hello(){ Echo 'Hello World!'; } Function index(){ Echo '此框架由Seven編寫,來自QQ群:223494678'; }

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Use subprocess.run() to safely execute shell commands and capture output. It is recommended to pass parameters in lists to avoid injection risks; 2. When shell characteristics are required, you can set shell=True, but beware of command injection; 3. Use subprocess.Popen to realize real-time output processing; 4. Set check=True to throw exceptions when the command fails; 5. You can directly call chains to obtain output in a simple scenario; you should give priority to subprocess.run() in daily life to avoid using os.system() or deprecated modules. The above methods override the core usage of executing shell commands in Python.

It is recommended to use the in keyword to check whether a key exists in the dictionary, because it is concise, efficient and highly readable; 2. It is not recommended to use the get() method to determine whether the key exists, because it will be misjudged when the key exists but the value is None; 3. You can use the keys() method, but it is redundant, because in defaults to check the key; 4. When you need to get a value and the expected key usually exists, you can use try-except to catch the KeyError exception. The most recommended method is to use the in keyword, which is both safe and efficient, and is not affected by the value of None, which is suitable for most scenarios.

Use fmt.Scanf to read formatted input, suitable for simple structured data, but the string is cut off when encountering spaces; 2. It is recommended to use bufio.Scanner to read line by line, supports multi-line input, EOF detection and pipeline input, and can handle scanning errors; 3. Use io.ReadAll(os.Stdin) to read all inputs at once, suitable for processing large block data or file streams; 4. Real-time key response requires third-party libraries such as golang.org/x/term, and bufio is sufficient for conventional scenarios; practical suggestions: use fmt.Scan for interactive simple input, use bufio.Scanner for line input or pipeline, use io.ReadAll for large block data, and always handle

Use the requests library and set stream=True to achieve efficient file download and avoid memory overflow; 2. Read data in chunks through response.iter_content and write files in binary mode, which is suitable for all types of file types; 3. You can automatically extract the original file name from the URL and save it with urlparse and os.path.basename; 4. It is recommended to add timeout parameters and simulate browser request headers to improve download stability; 5. Make sure that the URL is a direct file link, and pay attention to the access restrictions and disk space of the target website. This method is suitable for most common scenarios, and the file has been successfully downloaded as: downloaded_file.pdf.

InstallJDK,setJAVA_HOME,installJavaExtensionPackinVSCode,createoropenaMaven/Gradleproject,ensureproperprojectstructure,andusebuilt-inrun/debugfeatures;1.InstallJDKandverifywithjava-versionandjavac-version,2.InstallMavenorGradleoptionally,3.SetJAVA_HO

SQLServer itself does not support serverless architecture, but the cloud platform provides a similar solution. 1. Azure's ServerlessSQL pool can directly query DataLake files and charge based on resource consumption; 2. AzureFunctions combined with CosmosDB or BlobStorage can realize lightweight SQL processing; 3. AWSathena supports standard SQL queries for S3 data, and charge based on scanned data; 4. GoogleBigQuery approaches the Serverless concept through FederatedQuery; 5. If you must use SQLServer function, you can choose AzureSQLDatabase's serverless service-free

Lazy loading only queries when accessing associations can easily lead to N 1 problems, which is suitable for scenarios where the associated data is not determined whether it is needed; 2. Emergency loading uses with() to load associated data in advance to avoid N 1 queries, which is suitable for batch processing scenarios; 3. Emergency loading should be used to optimize performance, and N 1 problems can be detected through tools such as LaravelDebugbar, and the $with attribute of the model is carefully used to avoid unnecessary performance overhead.

To remove duplicate elements in Python list, 1. Use set(): It is suitable for situations where elements are immutable and do not care about order. The syntax is list(set(original_list)), but it will disrupt the original order; 2. Use dict.fromkeys(): The recommended method is suitable for Python 3.7, which can maintain the order of the first occurrence of elements. The syntax is list(dict.fromkeys(original_list)), and the code is concise and efficient; 3. Use list deduction and seed collection: It is suitable for scenarios where custom deduplication logic is required. By traversing the list and recording the seen elements with the set, ensuring uniqueness; 4. Handling non-hashable types such as
