ID: 39983 User updated by: mail at siegfried-bauer dot de -Summary: writing a backslash in a variable doesn't appear Reported By: mail at siegfried-bauer dot de Status: Bogus Bug Type: Strings related Operating System: Linux, kernel 2.6.16.13-4 PHP Version: 5.2.0 New Comment:
the problem is: fread calls addslashes after reading the file. fwrite calls stripslashes before writing the file. fprintf neither doesn't call stripslashes nor addslashes. so, when using fwrite you have to escape a \ four times. Previous Comments: ------------------------------------------------------------------------ [2006-12-29 15:05:52] mail at siegfried-bauer dot de try perl an d you receive what you will expect! #!/usr/bin/perl printf("This is a \\\n"); my $a=sprintf("\\"); printf("var \$a contains %s\n",$a); ------------------------------------------------------------------------ [2006-12-29 14:58:46] mail at siegfried-bauer dot de my old configuration: apache_1.3.31 php-4.3.3 kernel 2.4.21 worked different! ------------------------------------------------------------------------ [2006-12-29 10:55:23] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. ------------------------------------------------------------------------ [2006-12-29 08:11:23] mail at siegfried-bauer dot de Description: ------------ can't write a backslash into a variable. Reproduce code: --------------- #!/home/bauer/prog/php-5.1.6/sapi/cli/php <? $fp=fopen("out", "w"); printf("Hello World!\n with \\ one \\\n"); $s=sprintf("Hello World!\n with \\ one \\\n"); fwrite($fp, $s); fclose($fp); $fp=fopen("out2", "w"); fprintf($fp, "Hello World!\n with \\ one \\\n"); fclose($fp); ?> Expected result: ---------------- out doesn't contain any backslas. out2 yet. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39983&edit=1