fopen a+ without creating file with a BOM on Windows?
JAB Creations
2:45 am on Apr 1, 2011 (gmt 0)
I'm trying to test something out however PHP keeps generating the file with a BOM (byte order mark) which causes a lot of trouble for me.
Here is the code I'm playing around with...I need to write and write to the file and if it doesn't exist to create it though without the BOM if the file does not exist. Thoughts please?
I tried it on a Windows 7 64-bit system but I cannot recreate the issue, I do not get a BOM in the file. I just get a WARNING error,
Length parameter must be greater than 0
Apache 2.2.17 PHP 5.2.17
I wonder if adding the "b" to the end of your fopen mode would work.
$f = fopen($file,'a+b');
If not, maybe a stream context. Still, there must be something else at either the version of OS, version of server, version of PHP, file/directory defaults, etc. I'm curious what versions you are running too so I can try and replicate the environment and see if I can get the same results as you with a BOM.