Line endings difference Windows <-> Linux

Bo Berglund bo.berglund at gmail.com
Tue Jun 11 09:08:39 UTC 2013


On Tue, 11 Jun 2013 09:59:47 +0200, Patrick Asselman
<iceblink at seti.nl> wrote:

>PHP does not care how you end your lines for interpretation of the 
>code.
>
>BUT there are some risks, for instance if you print a string, the 
>string may come out differently, depending on how you coded it. Or if 
>you read a line of text from a file.
>
>My suggestion would be to find a good FTP program, and to make sure the 
>files are converted as they are transferred.
>For instance FileZilla has a sane default setting and knows that php 
>files are basically text files that need converting when transferred 
>from one system to the other. But all ftp programs have such a setting 
>(set "transfer type" to "auto" will do the trick).

What I was after was really to confirm weather or not I can stop
worrying about the line endings. Seems from your reply that for PHP
this is true as long as I don't have string manipulation code in php
that splits a string across several lines like:

$txt = " my new text here and then continue on the
following line like this";

Whereas this will work:
$txt = " my new text here and then continue on the " .
"following line like this";

Each substring contained within a single line...

Concerning the development and hosting:
I develop in my own environment using a Win7 PC as my main workstation
and a linux virtual machine with lamp-server as the test site.

But the hosting is done on Network Solutions and there I have no
control at all over almost anything, especially I do not have an
account that can be logged on and run commands on the server.

So rsync is not an option here, I must use an FTP client like
Filezilla. It will autodetect files, but I found that I have to:
1) Add the extensions that should be treated as ASCII
2) Not use sFTP because then everything seems to be transferred as
binary.
3) "Know" which files to transfer (i.e. which have been edited since
the last transfer) because it is not an option to always transfer
everything due to Internet upload bandwidth being so pitiful.


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list