Use PHP to modify the specified file suffix

Source: Internet
Author: User
Tags format modify

The most recent changes to the ASP suffix to PHP, because lazy in a change. Also think that PHP is the same as QT is a high-level language, the general high-level language has provided the content to be added to the search function. As a then, on the Internet search, and really a lot, so some will be the intention to sum up.

Objective: To change the ASP suffix in the current directory to PHP without affecting other "suffix format files," and only for "current folder", the files contained in the current folder are not modified.

The code is as follows:

!--? php function Foreachdir ($dirname) {if (!is_dir ($dirname)) {echo {$dirname} not
	  Effective dir;
	 Exit (); $handle =opendir ($dirname); Opens the directory while ($file = Readdir ($handle))!==false)//reads the directory {if ($file!=. && $file!=& #39; 
			& #39;) {if (Is_dir ($dirname. $file)) {echo $dirname. $file. 
; Foreachdir ($dirname. $file); If the annotation number is removed, the folder file in the folder will be recursively modified} else {echo--. $dirname./. $file.; $temp = substr ($file, Strrpos ($file, & #39;. & #39;) + 1); Get suffix format if ($temp = = ASP) {$pos = Strripos ($file, & #39;. & #39;); Gets the location of the filename $filename = substr ($file, 0, $pos); Gets the filename rename ($dirname. & #39;/& #39; $file, $dirname. & #39;/& #39; $filename #39; php& #39; Replace with the PHP suffix format. }}} foreachdir (& #39; /traversemendfilename& #39;);


-->

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.