Reputation: 2434
A bit of a strange problem here.
I am using FileZilla and Notepad++ on my work machine.
Basically whenever I upload a PHP script all the code turns into random characters
For example this code:
<?php echo 'hello world'; ?>
turns into
<?php 攀挀栀漀 ✀栀攀氀氀漀✀㬀ഀ ?>
My FTP transfer mode is set to ASCII. Am I doing anything wrong, is it a bad FTP setting?
Thanks Peter
Upvotes: 0
Views: 726
Reputation: 9401
Your ftp client botches the characterset of your input. Change the upload mode to binary and you're done.
Upvotes: 1
Reputation: 2034
good luck for your new office! xD
ftp trasfer with ASCII mode is (was) useful only if you are using plain text files and only if you have code, a script, that needs text files correctly encoded.
the ASCII mode actually means "handle this file as a text file"
text files that you may need to encode correctly are the "really text ones": txt, ini, conf (php outputs html/xml, then line endings are not relevant)
the replacements made by FTP ASCII mode, to the line ending bytes(s), may corrupt the entire file, with some encodings... actually this should not happen with UTF-8, then, apparently, you are using some other encoding...
in my opinion, in 2012, it is better to keep the file as it is uploaded: the client, the scripts and the applications should be able to parse correctly any text file of any system.
then: upload as binary, and be sure your scripts can handle any line ending bytes sequences
for instance if you need to split by line endings, use
// works everywhere with any file with any line ending
preg_split('/\r\n|\r|\n/', $text);
instead of
// works everywhere but only with files that contain
// line endings equivalent to the actual PHP_EOL content
explode(PHP_EOL, $text);
hoping to have been clear... feel free to correct my english!
Upvotes: 1