Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 如何实现thinkphp框架那种在浏览器地址栏里输入类中方法名即可访问

如何实现thinkphp框架那种在浏览器地址栏里输入类中方法名即可访问

Jun 20, 2016 pm 12:41 PM

如果用原生php的话每一个html页面都要对应一个php文件,感觉好麻烦。  
thinkphp框架却可以将所有的视图操作写成各个方法放在一个控制器类里面,再在地址栏里直接调用控制器类的方法。  
我想知道这是怎么弄的?






回复讨论(解决方案)

通过URL路由判断需要调用的类及方法,调用之。原理就这么简单。

我又看了一下,tp框架是通过一个index.php文件来判断url,从而跳转到不同的方法的吗?

根据 m 访问那个模块,根据 c 和 a 用反射(ReflectionMethod),调用方法  
在 \ThinkPHP\Library\Think\App.class.php 中可查到

 以上就是如何实现thinkphp框架那种在浏览器地址栏里输入类中方法名即可访问的内容,更多相关内容请关注PHP中文网(www.php.cn)!


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 Article Tags

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)

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to set the browser to start automatically when booting? How to automatically open the browser when Win11 is started? How to set the browser to start automatically when booting? How to automatically open the browser when Win11 is started? Jun 12, 2024 pm 07:58 PM

How to set the browser to start automatically when booting? How to automatically open the browser when Win11 is started?

Sesame Open Door Official Website Sesame Open Door App Latest Entering Website Sesame Open Door Official Website Sesame Open Door App Latest Entering Website Feb 28, 2025 am 11:18 AM

Sesame Open Door Official Website Sesame Open Door App Latest Entering Website

Clear the Google Chrome registry and clean up the remaining residue from uninstalling Google Chrome Clear the Google Chrome registry and clean up the remaining residue from uninstalling Google Chrome Jun 19, 2024 am 11:09 AM

Clear the Google Chrome registry and clean up the remaining residue from uninstalling Google Chrome

Where is the thinkphp homepage file? Where is the thinkphp homepage file? Apr 09, 2024 pm 05:54 PM

Where is the thinkphp homepage file?

The latest version of Sesame Open Door Official Website Entrance gate.io Official Website Link Address Entrance The latest version of Sesame Open Door Official Website Entrance gate.io Official Website Link Address Entrance Feb 28, 2025 am 11:21 AM

The latest version of Sesame Open Door Official Website Entrance gate.io Official Website Link Address Entrance

Which one is easier, thinkphp or laravel? Which one is easier, thinkphp or laravel? Apr 09, 2024 pm 06:00 PM

Which one is easier, thinkphp or laravel?

Reasons and solutions for slow browser network speeds (exploring the reasons for slow browser network speeds) Reasons and solutions for slow browser network speeds (exploring the reasons for slow browser network speeds) Apr 25, 2024 pm 03:49 PM

Reasons and solutions for slow browser network speeds (exploring the reasons for slow browser network speeds)

See all articles