Hi, i have a lot of php files that have a line between each line of code. For example, they look like this: <?php line1 line2 ?> Its so annoying, and i dont want to waste time getting rid of each line. I coded this myself, so could someone advise a program that i could use to get rid of these lines? Thank you
Format you code using PHP Formatter ---------------------- http://formatter.gerbenvv.nl/version3/index.php
Can I make a guess and say that you originally wrote that code in Windows and are now looking at it in UNIX / Linux? If I were to guess, I'd say it's an end-of-line character issue. The only problem with removing empty lines willy-nilly is that you will lose any empty lines you put there on purpose. Assuming my assumption about EOL is correct, I'd just grab an editor that works properly with either EOL and be done with it.
This happens to me sometimes to..it's so annoying. It has something to do with linux like the above mentioned. I'm guessing something to do with nano/ftp settings of the server >.>
It's not to do with the FTP server settings: if anything, it would be related to the FTP client. Windows EOL requires two characters: "\r\n". UNIX / Linux requires one: "\n". The "\r" is technically a different character (carriage return as opposed to a new line) but it's interpreted as such. Hence, when Windows creates a file with the two characters, UNIX / Linux sees that file and sees basically "\r" (which it displays as a new line) followed directly by the new line character resulting in every second line being blank (and empty). In theory an FTP client should be able to determine that a) it's grabbing a text file and hence b) rewrite the EOL character for the appropriate target OS. Like I said, though, it's best just to grab an editing environment that understands both (well all, actually, as Mac OS, for example, has a different EOL again).
Hmm, if you're a good coder you can create a good code that will do that for you.... There is a function like trim... So then do first the trim of the script, then the echo of the trimmed script
OK, I don't want to start a flamewar here, but I don't see the point in writing code to do this as if you move your code back and forth between different operating systems you would have to do this every time you want to use your code in a different OS. With a smart editor you don't even have to worry about silly little things like that. If you dual boot between Windows and Linux (for example) you could have the scripts on a 'shared' drive so that you don't even have to copy the code... no matter which OS you're in, you're using the same code. Maybe I'm missing something, but I really don't see the point to trying to work around this problem through code beautifiers (which won't necessarily work correctly) or your own code when the problem is solved with half decent editors... what am I missing here?