What is PHP framework? Why use PHP framework? This article will talk to you about the advantages of PHP frameworks, and summarize and share 11 of the most popular PHP frameworks in 2023. I hope it will be helpful to everyone!
1: What is the PHP framework?
The PHP framework is simply written in the PHP language. It can improve development efficiency, create more stable programs, and reduce repeated writing by developers during the project development process. As for the code infrastructure, the most popular ones in China are ThinkPHP and Laravel frameworks.
PHP中文網(wǎng)"The 23rd Three-month Live Class for PHP Novices to Daniels"We chose the ThinkPHP6 framework, which is the most commonly used in China and is the most suitable for entry-level teaching. (Note: 23 will start on March 9, 2023)
Registration consultation↓↓↓
QQ/WeChat: 27220243 (Teacher Zhong ), WeChat: phpcn01 (Teacher Yueyue)
(long press to identify and add WeChat)
2: Why use the PHP framework?
There are many advantages to using a PHP framework compared to coding from scratch using the native PHP language.
1. Speed ??up development progress
Because the PHP framework has built-in libraries and tools, it greatly shortens the time required for project development.
For example, the CakePHP framework has the Bake command line tool, which can quickly create any framework code needed in the application. Several popular PHP frameworks have integrated the PHPUnit library for easy testing.
2. Less code to write
Using the functions built into the framework means that there is no need to write too much original code.
3. There are many functional resource libraries
There are many common tasks that developers need to perform in web applications, such as form validation, data cleaning and CRUD operations ( Create, read, update and delete).
Using the framework, you don’t have to write your own functions for these tasks, just use the functions encapsulated by the framework.
4. Follow good coding practices
PHP frameworks usually follow coding best practices, for example, they neatly divide the code into multiple directories based on functionality. .
#These directories force you to organize your code in a cleaner, neater, and more maintainable way.
The framework also has its own naming conventions for variables, directories, spaces, etc. You should follow these conventions.
5. More secure than applications written by yourself
There may be many PHP security threats after the project goes online, including cross-site scripting, SQL injection attacks and cross-site requests Forgery. Unless you take the correct countermeasures to protect your program, your PHP web application will be vulnerable to attacks.
While using a PHP framework does not replace writing secure code, it can minimize the opportunities for hackers to exploit vulnerabilities. Good frameworks have built-in data cleaning capabilities that protect against the common threats mentioned above.
6. Better teamwork
Projects developed by the team may go wrong if the following aspects are not clear:
Documentation
Design Decisions
Normative Standards
Use a framework to set clear goals for the project basic rules. Even if other developers are unfamiliar with the framework, they are able to quickly learn and work together.
7. Easy to maintain
The PHP framework encourages code refactoring and promotes DRY development (DRY-Don't Repeat Yourself), resulting in a more streamlined The code base requires less maintenance.
You also don’t have to worry about maintaining the framework core because the framework developers will do it for you.
3: What you need to know before using the PHP framework
1. PHP native basics
Before using the PHP framework, you must first master the native basics of PHP!
If you don’t have a good grasp of the language, it will be difficult for you to master the PHP encapsulated framework.
Recommended tutorials:
Free public welfare courses:
01. "Little White Savior: PHP7 Basics" Quick syntax preview》
http://www.miracleart.cn/course/1147.html
02.《php8, I’ll do it》
http://www.miracleart.cn/course/1188.html
Paid course:
01.VIP會員專屬課:前端+后端PHP+實戰(zhàn)(錄制課)
http://www.miracleart.cn/vip.html
02.線上直播班:前端+后端PHP+綜合實戰(zhàn)(含輔導解答、作業(yè)批改)
http://www.miracleart.cn/k.html
2. 面向對象
了解PHP面向對象編程也是必不可少的一步,因為大多數(shù)現(xiàn)代PHP框架都是面向對象的,確保理解類、對象、繼承、方法、 traits和訪問修飾符等概念。
3. 數(shù)據(jù)庫
由于許多web應用程序的數(shù)據(jù)獲取都需要連接數(shù)據(jù)庫,因此您應該了解數(shù)據(jù)庫和SQL語法,每個PHP框架都有自己受支持的數(shù)據(jù)庫列表。
4. 對象關系映射(ORM)模型
ORM是一種使用面向對象語法而不是SQL語法訪問數(shù)據(jù)庫數(shù)據(jù)的方法,使用ORM,您可以用熟悉的PHP編寫數(shù)據(jù)庫查詢,但有時也可能需要使用SQL語句。
許多PHP框架都內(nèi)置了自己的ORM,例如,Laravel使用了Eloquent ORM。其他框架則使用一種類似于ORM的開源原則。
5. WEB服務器環(huán)境
了解Apache和Nginx等web服務器的工作原理對于框架的使用也是很有幫助的,因為您可能需要在服務器上配置文件,以使應用程序以最佳方式運行。
您可能會在本地進行大部分開發(fā),因此您也需要了解localhost。另一種選擇是使用Vagrant和VirtualBox在虛擬環(huán)境中創(chuàng)建和測試應用程序。
6. 模型-視圖-控制器架構模式
PHP框架通常遵循模型-視圖-控制器(MVC)設計模式。這個概念將數(shù)據(jù)的操作與數(shù)據(jù)的渲染分離開來。
Model模型存儲業(yè)務邏輯和應用程序數(shù)據(jù),它將數(shù)據(jù)傳遞給視圖層。用戶與視圖交互,然后交由控制器處理這些交互指令,接著控制器向模型發(fā)出這些指令,循環(huán)繼續(xù)。
簡而言之:
模型是關于數(shù)據(jù)的,
視圖是關于頁面渲染的,
控制器是關于行為的。
關于MVC模式的工作原理,我們可以類比在酒吧點雞尾酒。
用戶就好比到達酒吧(視圖
)需要酒水的顧客,用戶將他們的酒水訂單交給酒保(控制器
)。
控制器根據(jù)模型——配方、配料和設備完成訂單。根據(jù)雞尾酒的不同,他們可能會使用以下任何一種或其他物品:
·含酒精飲料 ·果汁 ·冰 ·檸檬 ·玻璃 ·雞尾酒搖壺 ·油橄欖 ·攪拌器
成品雞尾酒放在吧臺上供用戶享用。如果用戶想再喝一杯,他們必須先與控制器通話。他們不允許進入模型并調(diào)制自己的飲料。
在PHP應用程序術語中,MVC可以對應以下內(nèi)容:
模型:數(shù)據(jù)庫
視圖:一個或多個HTML頁面
控制器:訪問和更新數(shù)據(jù)庫的功能
7. 命令行界面(CLI)
Laravel有自己的CLI Artisan控制臺。使用Artisan中的“生成”命令,可以快速構建項目的模型、控制器和其他組件。
熟悉命令行也是使用Composer PHP包管理器的關鍵。Yii框架是使用Composer來安裝和管理項目依賴 (應用程序運行所需的包)的幾種框架之一。
Packagist是可以使用Composer安裝的軟件包的主要存儲庫。一些最流行的Composer軟件包使用Symfony框架運行。
五:您應該如何考量一款PHP框架好不好?
以下是小編為您總結的為項目選擇最佳PHP框架時需要考慮的一些因素:
首先,如果您剛接觸PHP框架,學習路線不應該太曲折。
如果框架太難掌握,你就不想花寶貴的時間學習它。幸運的是,PHP是最容易學習的編程語言之一。
接下來,您需要一個易于使用并節(jié)省時間的框架。
The PHP framework should meet the technical requirements of your project, most frameworks have a minimum PHP version and certain PHP extensions they use.
Additionally, you need to make sure that the framework you choose supports the database you choose and that you can use the framework with the web server you are deploying to.
Choose a framework with balanced functionality. For some projects, a feature-rich framework can be a boon, and if you don't need many features, then opt for a stripped-down framework.
Some important features include:
Testing
- ##Cache Storage
- Template Engine: A way to output PHP in HTML using PHP classes
- Safety
Finally, if you want to use the PHP framework flexibly, you cannot do without good documentation and ecological support.
A framework with a large and vibrant community is also more likely to stand the test of time and be able to help you when you get stuck.Six: What are the best PHP frameworks in 2022?
The following are some of the best PHP frameworks currently in use:1.ThinkPHP (Most used in China, easy to get started, suitable for beginners )
2. Laravel (Most used in the world, known as the most elegant framework, difficult to get started)
#3. Symfony
4. CodeIgniter (referred to as CI, very lightweight)
5. Zend Framework / Laminas Project
6. Yii (Framework) (mostly used in domestic and foreign trade industries)
7. CakePHP
8. Slim
9. Phalcon
10. FuelPHP
##11. Fat-Free FrameworkThinkPHP
ThinkPHP was developed by Chinese people and is a free, open source, object-oriented, lightweight PHP development framework. Born in early 2006, it is the most used in China. The 23rd PHP live class teaching project of
uses ThinkPHP6, which is very suitable for beginners! Popular version
- ThinkPHP5.x: Launched in 2015, MVC mode, supports PHP>=5.6
- ThinkPHP6. x: Newly launched in 2019, start using Composer to install and update, support PHP>=7.1
Billed as the "PHP framework for web craftsmen," Laravel was developed by Taylor Otwell, who wanted a framework that included features that CodeIgniter didn't have, such as user authentication.
Laravel quick introduction
Release date: June 2011
Current version: Laravel8 - Released on September 8, 2020. Technical requirements:##PHP>=7.2.5 (or use Laravel Homestead)
Supports Composer installation
The database supports MySQL 5.6, PostgreSQL 9.4, SQLite 3.8.8, and SQL Server 2017.
- Advantages of Laravel
Laravel Homestead is Lavarel’s official pre-packaged Vagrant Box, which provides you with an excellent development environment. There is no need for you to install PHP, Web server and any other server software on your local machine. Mom no longer has to worry about messing up your operating system! If you are a Mac user, you can also choose to use Laravel Valet as your development environment. Laravel Valet supports frameworks such as Symfony, CakePHP 3, Slim and Zend, and WordPress.
Laravel uses a template engine called Blade. One advantage it has over other template engines is that it can use PHP in Blade, which other engines cannot.
Packalyst is a collection of Laravel software packages, with more than 15,000 software packages that can be used in projects.
Laravel provides a range of security features and methods, including the following:
Authentication
Authorization
Email Verification
Encryption
Hash
Password reset
Laravel Eloquent ORM and Fluent Query Builder prevent SQL injection attacks when using PDO parameter binding.
Cross-site request forgery (CSRF) protection is also enabled by default, and whenever you define an HTML form in your application, you should include a hidden CSRF _token field in the form.
Artisan Console for Laravel The command line tool speeds up development by allowing developers to automate repetitive tasks and quickly generate framework code.
If you need to benchmark PHP, Laravel is the fastest PHP framework you can choose from.
The Laravel ecosystem has several useful tools, such as Mix for compiling CSS and JS resources, and Socialite for OAuth authentication.
Laravel benefits from a large developer community (like WordPress).
The editor has compiled some community addresses for you:
Laracasts: Learning portal including courses, blogs, podcasts and forums
Laravel.io: A community portal with over 45,000 users.
The Laravel subreddit: A community portal for 50,000 Laravel artisans.
laravel video tutorial:
http://www.miracleart.cn/course/list/23.html
laravel technical articles:
http://www.miracleart.cn/phpkj/laravel/
Course Recommendation:
#Laravel 9 Newly launched on the Chinese website "Laravel 9 is the time to learn - nanny-level tutorial, it is difficult to learn!"
》Take you to experience Laravel 9, the latest version of the PHP framework specially built for Web craftsmen, making your code more like the work of an artist!Opening address: http://www.miracleart.cn/course/1421.html
Symfony
Symfony quick introduction
Release date: October 2005 Current version: Symfony5.1.4Technical requirements:- PHP>=7.2.5
- Support Composer installation
Symfony Advantages
Symfony is the best choice for websites and applications that require scalability. Its modular component system is flexible, allowing you to choose the components you need for a variety of projects. Symfony supports most databases in popular PHP frameworks:- Drizzle
- MySQL
- Oracle
- PostgreSQL
- SAP Sybase SQL Anywhere
- SQLite
- SQLServer
Using the built-in toolbarDebugging
Debugging a Symfony project is very easy.Symfony uses the Twig
template engine which is easy to learn, fast and secure.Packagist lists more than 4000 Symfony packages
ready for you to download and use. Symfony has commercial support from Sensio Labs. This means that unlike most other PHP frameworks, Symfony has a professional support team and it also has long-term version support, with a support period of 3 years.CodeIgniter
CodeIgniter框架可以幫助您快速構建web應用程序,因為它具有最小的配置。
CodeIgniter快速了解
發(fā)布日期:2006年2月
當前版本:CodeIgniter4.0.3
技術要求:
PHP>=7.2
數(shù)據(jù)庫支持MySQL、PostgreSQL、SQLite3
CodeIgniter的優(yōu)點
CodeIgniter以其運行速度著稱,它是我們在PHP基準測試中嘗試的四個PHP框架中速度第二快的。
CodeIgniter框架的占用資源很?。?.2MB),您可以添加所需的組件。
CodeIgniter很靈活:它鼓勵使用MVC架構進行開發(fā),但您也可以編寫非MVC應用程序。
該框架內(nèi)置了對CSRF和XSS攻擊的防御措施,以及上下文相關的轉義和內(nèi)容安全策略。
CodeIgniter支持多種緩存方法,以加快應用程序的運行速度。
如前所述,與其他框架相比,CodeIgniter具有簡單的學習曲線,并且具有很強的可擴展性。
CodeIgniter的社區(qū)由一個論壇和Slack組組成。
推薦教程:
《CI框架30分鐘極速入門》
http://www.miracleart.cn/course/760.html
Zend Framework / Laminas Project
Zend框架是一個久負盛名的PHP框架,現(xiàn)在正在向Laminas Project過渡。
如果您的項目正在使用Zend, 小編強烈建議您將項目遷移到Laminas,因為Zend不再更新。
Laminas Project由3部分組成:
1. Laminas組件和MVC
2. Mezzio
3. Laminas API工具
Laminas 快速了解
發(fā)布日期:2006年2月
當前版本:3.0.0 (Zend) or 1.3.0 (Laminas)
技術要求:
PHP>=5.6(Zend)或>=7.3(Laminas)
支持Composer方式的安裝
數(shù)據(jù)庫支持MariaDB、MySQL、Oracle、IBM DB2、Microsoft SQL Server、PostgreSQL、SQLite和Informix Dynamic Server
Laminas/Zend的優(yōu)點
Zend框架的下載量超過5.7億,它也是企業(yè)使用最多的PHP框架。Zend遵循PHP框架互操作組(PHP Framework Interop Group 簡稱為PHP-FIG)標準,這意味著其代碼可以輕松地移植到其他框架。
與Symfony一樣,您可以使用所需的組件,您可以使用Zend構建RESTful API。
Laminas社區(qū)有一個論壇和Slack組,用于開發(fā)者協(xié)作和框架支持。
Yii (Framework)
這個框架的名字叫Yii,在漢語中的意思是“簡單而進化”。它還代表“Yes, It Is!”
Yii 快速了解
發(fā)布日期:2008年10月
當前版本:Yii2.0.35
技術要求:
PHP>=5.4.0 推薦PHP7以上版本
支持Composer方式的安裝
數(shù)據(jù)庫支持SQLite、MySQL、PostgreSQL、MSSQL或Oracle
Yii 的優(yōu)點
你可以在幾分鐘內(nèi)快速上手。因為它的文檔編寫良好,易于理解。
Yii框架有幾個安全措施,如bcrypt密碼哈希、加密、身份驗證和授權。它的文檔中提供了防止SQL注入、XSS和CSRF攻擊的最佳實例,不容錯過。
Gii代碼生成器可以快速為您構建骨架代碼,節(jié)省開發(fā)時間。
Yii支持四種類型的緩存來加速web應用程序:數(shù)據(jù)緩存、片段緩存、頁面緩存和HTTP緩存。
您可以在Yii項目中運行第三方代碼。
Yii社區(qū)通過Slack或IRC提供在線實時支持。Yii的生態(tài)圈還包括一個討論論壇和社交媒體渠道。該社區(qū)向其活躍成員頒發(fā)名人堂徽章和參賽機會。
Yii框架視頻教程推薦:
http://www.miracleart.cn/toutiao-362431.html
CakePHP
CakePHP是一個快速、干凈的PHP開發(fā)框架。
CakePHP 快速了解
發(fā)布日期:2005年4月
當前版本:CakePHP4.1.1
技術要求:
PHP>=7.2 推薦PHP7.4
支持Composer方式的安裝
數(shù)據(jù)庫支持MySQL 5.6+, MariaDB 5.6+, PostgreSQL 9.4+, SQLite 3.8, SQL Server 2012+
CakePHP的優(yōu)點
CakePHP配置最少、最容易上手,因為您不必處理XML或YAML文件。一旦完成了數(shù)據(jù)庫配置,就可以開始愉快編碼了。
CakePHP有自己的內(nèi)置ORM,使用起來既快速又簡單,它的安全特性包括加密、密碼哈希、表單數(shù)據(jù)保護和CSRF防御。
CakePHP的組件和助手函數(shù)簡化了開發(fā),減少了您必須執(zhí)行的普通任務的數(shù)量。
Github提供了一個有用的CakePHP資源和插件列表。
https://github.com/friendsofcake/awesome-cakephp
Slim
Slim是一個精簡、靈活的微型PHP框架,由JoshLockhart創(chuàng)建。它關注于接收HTTP請求、調(diào)用回調(diào)和返回HTTP響應。
Slim 快速了解
發(fā)布日期:2010年9月?
當前版本:Slim4.5.0?
技術要求:
PHP>=7.2
具有URL重寫的Web服務器
Slim的優(yōu)點
Slim的代碼庫很精簡,因為它沒有第三方依賴關系,因此,運行速度非???。
Slim特別適合構建小型應用程序和程序接口,此外Slim還集成了第一方和第三方組件。
Slim很容易學習和理解。你可以在幾分鐘內(nèi)運行一個“Hello World”應用程序。Slim被Sland網(wǎng)站上的開發(fā)人員評為最佳的PHP框架。
Tidelift提供對Slim的專業(yè)支持。
Phalcon
Phalcon是為提高速度而構建的PHP框架,它最初是作為以Zephir和C編寫的web服務器的擴展而出現(xiàn)的,但是您不需要了解C。Phalcon可以使開發(fā)人員使用由框架生成的PHP類和命名空間。
Phalcon 快速了解
發(fā)布日期:2012年11月?
當前版本:Phalcon4.0.6
技術要求:
PHP>=7.2
PSR擴展
Phalcon的優(yōu)點
Phalcon設計的初衷是使項目快速運行,因為它具有以下特點:
架構簡單。
Zephir、C擴展和PHP的一次性加載。
代碼是編譯的,而不是解釋的,因此速度更快。
內(nèi)存常駐,意味著您可以隨時在需要時調(diào)用它。
與大多數(shù)其他PHP框架不同,Phalcon不使用文件讀取和文件統(tǒng)計信息,從而提高了性能。
由于Phalcon是松散耦合的,因此您可以創(chuàng)建自己的目錄結構,再者Phalcon底層代碼不存在于項目目錄中,這一點使得代碼變得很輕量級。
Phalcon的安全組件有助于密碼哈希和CSRF保護,模板引擎Volt速度非??欤⑶腋綆Я撕芏鄶U展類庫,可以幫助您輕松創(chuàng)建視圖。
遇到任何問題,您可以通過Phalcon的文檔、論壇、Discord chat、Stack Overflow和多個社交媒體平臺尋求解決方案與支持。
FuelPHP
FuelPHP是一個社區(qū)驅動的PHP框架,由300多個貢獻者參與完成。
FuelPHP 快速了解
發(fā)布日期:2011年6月?
當前版本:FuelPHP1.8.2
技術要求:
PHP>=5.4
任何wed服務器
FuelPHP的優(yōu)點
FuelPHP也采用了MVC架構模式,但也支持HMVC(Hierarchical Model View Controller),即在控制器和視圖之間添加另一層。
HMVC設計模式的優(yōu)點是:
更好的代碼組織
更大的模塊化
更具擴展性
鼓勵代碼重用
您可以為您的項目選擇所需要的文件和文件夾結構,因為FuelPHP在這方面的約束很少。
此外,F(xiàn)uelPHP非常重視安全性,具有以下特性:
輸出編碼?
CSRF保護?
輸入、URI和XSS過濾?
用戶的輸入會被轉義后才參與組建SQL語句
FuelPHP has its own command line utility - oil, which you can use to perform tasks, debug code and generate public components.
In addition, FuelPHP’s ORM function is very powerful, but it is also very lightweight. You can join the FuelPHP community on the FuelPHP forum, Facebook and Twitter.
Fat-Free-Framework
Fat-Free-Framework quick introduction
Release date: 2009Current version: Fat-Free-Framework3.7.2Technical requirements:- PHP>=5.4
- The database supports MySQL, SQLite, MSSQL/Sybase, PostgreSQL and MongoDB.
Advantages of Fat-Free-Framework
The code base of F3 is about 65Kb, so it runs very fast, even though it is very light , F3 still has all the features you expect. You can extend the framework as needed using optional plugins. F3 is very easy to get started with. It works right out of the box. No need to use Composer, curl or dependency injection to get started. You can create a Hello World application in minutes. Almost all elements of F3 are modular, so you can use only the parts you need to build your web application. F3 by default does not add code you don’t need, making your application Stay in the most "capable" state. F3’s documentation is also very clear and easy to understand, with a large number of example demonstrations. The Fat-Free framework offers a choice of template engines: you can use PHP, F3's own template engine, or other template engines such as Smarty or Twig. F3 developers are generally active on Slack and the Fat-Free Framework Google Group.Seven: Which PHP framework is best for beginners?
For beginners, it is best to choose frameworks that are simpler and more suitable for Chinese people in the starting stage, such as the ThinkPHP framework.So which PHP framework is your favorite and why? Let us know in the comments below!

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

The method to get the current session ID in PHP is to use the session_id() function, but you must call session_start() to successfully obtain it. 1. Call session_start() to start the session; 2. Use session_id() to read the session ID and output a string similar to abc123def456ghi789; 3. If the return is empty, check whether session_start() is missing, whether the user accesses for the first time, or whether the session is destroyed; 4. The session ID can be used for logging, security verification and cross-request communication, but security needs to be paid attention to. Make sure that the session is correctly enabled and the ID can be obtained successfully.

To extract substrings from PHP strings, you can use the substr() function, which is syntax substr(string$string,int$start,?int$length=null), and if the length is not specified, it will be intercepted to the end; when processing multi-byte characters such as Chinese, you should use the mb_substr() function to avoid garbled code; if you need to intercept the string according to a specific separator, you can use exploit() or combine strpos() and substr() to implement it, such as extracting file name extensions or domain names.

UnittestinginPHPinvolvesverifyingindividualcodeunitslikefunctionsormethodstocatchbugsearlyandensurereliablerefactoring.1)SetupPHPUnitviaComposer,createatestdirectory,andconfigureautoloadandphpunit.xml.2)Writetestcasesfollowingthearrange-act-assertpat

In PHP, the most common method is to split the string into an array using the exploit() function. This function divides the string into multiple parts through the specified delimiter and returns an array. The syntax is exploit(separator, string, limit), where separator is the separator, string is the original string, and limit is an optional parameter to control the maximum number of segments. For example $str="apple,banana,orange";$arr=explode(",",$str); The result is ["apple","bana

JavaScript data types are divided into primitive types and reference types. Primitive types include string, number, boolean, null, undefined, and symbol. The values are immutable and copies are copied when assigning values, so they do not affect each other; reference types such as objects, arrays and functions store memory addresses, and variables pointing to the same object will affect each other. Typeof and instanceof can be used to determine types, but pay attention to the historical issues of typeofnull. Understanding these two types of differences can help write more stable and reliable code.

std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)

In PHP, to pass a session variable to another page, the key is to start the session correctly and use the same $_SESSION key name. 1. Before using session variables for each page, it must be called session_start() and placed in the front of the script; 2. Set session variables such as $_SESSION['username']='JohnDoe' on the first page; 3. After calling session_start() on another page, access the variables through the same key name; 4. Make sure that session_start() is called on each page, avoid outputting content in advance, and check that the session storage path on the server is writable; 5. Use ses

When encountering the problem that header('Location:...') does not work, the common reasons and solutions are as follows: 1. There is output in advance, causing the header to fail. The solution is to ensure that there is no output before the jump, including spaces, HTML or echo; 2. There is excess output or UTF-8 BOM characters in the include or require file. The file encoding should be checked and saved as "UTF-8 BOM-free"; 3. It is recommended to use ob_start() to turn on the output buffer before the jump, and cooperate with ob_end_flush() to delay the output; 4. After the jump, be sure to add exit to prevent subsequent code execution; 5. Make sure that the header() function call is before all outputs.