How to get only the file name in php

藏色散人
Release: 2023-03-10 14:48:01
Original
1791 people have browsed it

How to get only the file name in php: first create a PHP sample file; then get the file part through the "basename($file_path);" method; finally get the file name through the "substr()" method .

How to get only the file name in php

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

How does php only get the file name?

php gets the file name of the file (misunderstanding)

File path: $path = '/home/files/1234.jpg';

php gets the file name, everyone You should be familiar with it. Write a small function and call the function echo get_fileName($path) in minutes

Copy after login

; // Output 1234

Look carefully, there is nothing wrong with it. What is the problem? Is it? Now it’s time to witness the miracle

Now comes a new file path/home/upload/abc.123.test.zip

Call the function again, and the result is abc

this. . .

Now you know what the problem is!

Okay, the complete method is as follows

Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to get only the file name 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!