Home > Backend Development > PHP Problem > How to implement custom url in php

How to implement custom url in php

藏色散人
Release: 2023-03-11 19:32:01
Original
2874 people have browsed it

How to implement custom URLs in PHP: 1. Configure the htaccess file through mod_rewrite to implement URL rewriting; 2. Use the PATH_INFO function that comes with PHP to implement rewriting.

How to implement custom url in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How does php implement a custom url?

1. Configure the .htaccess file through mod_rewrite to implement URL rewriting, which requires the server to support rewrite

2. Use the PATH_INFO function that comes with PHP to implement rewriting, and implement it through the PHP program.

Related introduction:

pathinfo() function returns information about the file path in the form of an array.

The returned array elements are as follows:

[dirname]: Directory path

[basename]: File name

[extension]: File suffix name

[filename]: File name without suffix

Syntax

pathinfo(path,options)
Copy after login

Parameters

path required. Specifies the path to be checked.

options Optional. Specifies the array elements to be returned. The default is all.

Possible values:

PATHINFO_DIRNAME - 只返回 dirname
PATHINFO_BASENAME - 只返回 basename
PATHINFO_EXTENSION - 只返回 extension
PATHINFO_FILENAME - 只返回 filename
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to implement custom url in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source: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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template