web服务器上使用的file_put_contents编码?

I am trying to use file_put_contents (and file_get_contents for that matter) with a UTF-8 ¥ following this stackoverflow post: How to write file in UTF-8 format? which uses:

$data = mb_convert_encoding($data, 'UTF-8', 'OLD-ENCODING');

Which wasn't really explained well, since it produces an error of:

mb_convert_encoding(): Illegal character encoding specified

So 'OLD-ENCODING' was just a placeholder they were using. The question I have is what encoding should I change this to? ASCII or ISO-8859-1? What encoding do most web hosts use? Does it matter?

When I open the file, I will get the symbol correctly, only if I have my notepad set with encoding UTF-8. If I open it with another character set it will show up with a "?".

Try without third parameter.

$str = mb_convert_encoding($str, "UTF-8");

Or auto:

$str = mb_convert_encoding($str, "UTF-8", "auto");

More info and examples on: http://php.net/manual/function.mb-convert-encoding.php

mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));

mb_detect_encoding