how to remove unwanted spaces in a php file
when i download files from server i found many unwanted spaces开发者_StackOverflow社区 in that file.why those spaces are coming? is there any way to remove those spaces. Please help me..
We use dreamweaver here at the office along with SVN for our source control. We couldn’t figure out for the life of us what what causing many, many extra lines to appear in our code after multiple commits/uploads. Finally a Google search provided the answer.
How to remove extra spaces
While the document is open in Dreamweaver, press CTRL+F to load the Find & Replace dialog box. Do the search on the source code view.
Check the box “Use regular expression” and uncheck any other boxes.
Find: [\r\n]{2,}
Replace: \n
The hit “replace all”
That’s it!
However, take note that this method will remove any existing white space on your code.
Another thing. When you download the file again, Dreamweaver will add another white space on your code. Messing it up again. This is because of encoding and server type.
This usually happens if you are using Dreamweaver CS3 and your are downloading a file from a Unix/Linux server to a Windows based local PC.
Change Your Dreamweaver Settings to Prevent it
Inside Dreamweaver, click Edit on the menu.
Then Preferences.
Then Code Format.
Then on the “Line Break Type” select “LF (unix)”
Click Ok. Done!
This is the ultimate answer...give this guy reward.. http://www.jaredstenquist.com/2009/02/13/removing-extra-linebreaks-and-spaces-in-dreamweaver/
It could be your FTP client up/downloading the file in "ASCII" mode. Make sure you've configured it to transfer all files in binary mode.
Another possibility to follow is that you're using different editors/operating systems and they don't agree on the newline convention. Use a good text editor like Notepad++ that understands all newlines.
精彩评论