Use php to modify the specified file suffix

Source: Internet
Author: User
Using php to modify the suffix of a specified file recently changes the suffix of asp to php. I think php and Qt are both advanced languages. generally, advanced languages provide functions for adding, deleting, modifying, and querying the obtained content. As a result, I searched the internet and found a lot, so I summarized some of my experiences.

Objective: to change the asp suffix in the current directory to php without affecting other "files in the suffix format", and only for the "current folder ", do not modify the files in the current folder.

The code is as follows:

 "; // ForeachDir ($ dirname. $ file); // if the comment is removed, the folder file in the folder will be recursively modified} else {echo "--". $ dirname. "/". $ file."
"; $ Temp = substr ($ file, strrpos ($ file ,'. ') + 1); // Obtain the suffix format if ($ temp = "asp") {$ pos = strripos ($ file ,'. '); // get the location of the file name $ filename = substr ($ file, 0, $ pos); // Get the rename ($ dirname. '/'. $ file, $ dirname. '/'. $ filename. '. php '); // replace it with the php suffix format. }}}} ForeachDir ('../traverseMendFilename');?>

Also: attach four methods to get the file extension: http://www.jb51.net/article/29765.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.