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極簡框架 </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ù)錯誤!'<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的值為空,則訪問默認的index方法 IF(!is_callable($w)) { //如果$w所屬的function不存在 Exit('Error:'.__LINE__.',參數(shù)錯誤!'); //拋出錯誤 } $w(); //調(diào)用$w名稱對應的function,例如:http://URL/hello會調(diào)用hello()這個function //自定義方法(可自由擴展) 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

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

The future of C will focus on parallel computing, security, modularization and AI/machine learning: 1) Parallel computing will be enhanced through features such as coroutines; 2) Security will be improved through stricter type checking and memory management mechanisms; 3) Modulation will simplify code organization and compilation; 4) AI and machine learning will prompt C to adapt to new needs, such as numerical computing and GPU programming support.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ??such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ??have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Python excels in automation, scripting, and task management. 1) Automation: File backup is realized through standard libraries such as os and shutil. 2) Script writing: Use the psutil library to monitor system resources. 3) Task management: Use the schedule library to schedule tasks. Python's ease of use and rich library support makes it the preferred tool in these areas.

Python excels in gaming and GUI development. 1) Game development uses Pygame, providing drawing, audio and other functions, which are suitable for creating 2D games. 2) GUI development can choose Tkinter or PyQt. Tkinter is simple and easy to use, PyQt has rich functions and is suitable for professional development.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.
