php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30064 Can't redirect to a file.
Submitted: 2004-09-11 23:44 UTC Modified: 2005-02-20 01:00 UTC
From: jkawa at m dot email dot ne dot jp Assigned:
Status: No Feedback Package: Output Control
PHP Version: 5.0.1 OS: FreeBSD 4.8-RELEASE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jkawa at m dot email dot ne dot jp
New email:
PHP Version: OS:

 

 [2004-09-11 23:44 UTC] jkawa at m dot email dot ne dot jp
Description:
------------
configure options:
--with-apxs --with-pgsql --enable-zend-multibyte --enable-mbstring --enable-versioning --with-pear --enable-ftp --enable-sockets

diff php.ini-dist php.ini:
82a92
> ;short_open_tag = Off
86c96
< asp_tags = Off
---
> asp_tags = On
89c99
< precision    =  12
---
> precision    =  14
101c111
< output_buffering = Off
---
> output_buffering = 4096
113,115c123
< ; Note: output_handler must be empty if this is set 'On' !!!!
< ;       Instead you must use zlib.output_handler.
< ;output_handler =
---
> output_handler = mb_output_handler
121,125c129,133
< ;       outputs chunks that are few hundreds bytes each as a result of
< ;       compression. If you prefer a larger chunk size for better
< ;       performance, enable output_buffering in addition.
< ; Note: You need to use zlib.output_handler instead of the standard
< ;       output_handler, or otherwise the output will be corrupted.
---
> ;       outputs chunks that are few handreds bytes each as a result of compres
sion.
> ;       If you want larger chunk size for better performence, enable output_bu
ffering
> ;       also.
> ; Note: output_handler must be empty if this is set 'On' !!!!
> ;       Instead you must use zlib.output_handler.
163c171
< allow_call_time_pass_reference = On
---
> allow_call_time_pass_reference = Off
260c268
< ; E_STRICT                    - run-time notices, enable to have PHP suggest c
hanges
---
> ; E_STRICT          - run-time notices, enable to have PHP suggest changes
280c288
< ;error_reporting = E_ALL & ~E_NOTICE
---
> error_reporting = E_ALL & ~E_NOTICE
286c294
< ;   - Show all errors except for notices and coding standards warnings
---
> ;   - Show all errors
288c296
< error_reporting  =  E_ALL & ~E_NOTICE & ~E_STRICT
---
> ;error_reporting  =  E_ALL
305c313
< log_errors = Off
---
> log_errors = On
374c382
< variables_order = "EGPCS"
---
> variables_order = "GPCS"
390c398
< register_long_arrays = On
---
> register_long_arrays = Off
395c403
< register_argc_argv = On
---
> register_argc_argv = Off
404c412
< magic_quotes_gpc = On
---
> magic_quotes_gpc = Off
433a442
> include_path = ".:/usr/local/poison:/php/includes"
445c454
< ; The directory under which PHP opens the script using /~username used only
---
> ; The directory under which PHP opens the script using /~usernamem used only
513,514c522,523
< ; Define the User-Agent string
< ; user_agent="PHP"
---
> ; Define the user agent for php to send
> ;user_agent="PHP"
620c629
< ;mail.force_extra_parameters =
---
> ;mail.force_extra_paramaters =
688c697
< ; SQL-Errors will be displayed.
---
> ; SQL-Erros will be displayed.
752c761
< pgsql.log_notice = 0
---
> pgsql.log_notice = 1
803c812
< dbx.colnames_case = "unchanged"
---
> dbx.colnames_case = "lowercase"
913c922
< session.gc_divisor     = 100
---
> session.gc_divisor     = 1000
919,926d927
< ; NOTE: If you are using the subdirectory option for storing session files
< ;       (see session.save_path above), then garbage collection does *not*
< ;       happen automatically.  You will need to do your own garbage
< ;       collection through a shell script, cron entry, or some other method.
< ;       For example, the following script would is the equivalent of
< ;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
< ;          cd /path/to/sessions; find -cmin +24 | xargs rm
<
933c934
< session.bug_compat_42 = 1
---
> session.bug_compat_42 = 0
951c952
< ; Set to {nocache,private,public,} to determine HTTP caching aspects
---
> ; Set to {nocache,private,public,} to determine HTTP caching aspects.
980c981
< session.hash_bits_per_character = 4
---
> session.hash_bits_per_character = 5
987c988
< url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
---
> url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
1110,1111c1111,1112
< ;mbstring.language = Japanese
<
---
> mbstring.language = Japanese
> mbstring.script_encoding = auto
1115c1116
< ;mbstring.internal_encoding = EUC-JP
---
> mbstring.internal_encoding = EUC
1118c1119
< ;mbstring.http_input = auto
---
> mbstring.http_input = auto
1122c1123
< ;mbstring.http_output = SJIS
< ;mbstring.http_output = SJIS
---
> mbstring.http_output = SJIS
1129c1130
< ;mbstring.encoding_translation = Off
---
> mbstring.encoding_translation = On
1133c1134
< ;mbstring.detect_order = auto
---
> ;mbstring.detect_order = SJIS-win,EUCJP-win
1185,1193d1185
<
< [soap]
< ; Enables or disables WSDL caching feature.
< soap.wsdl_cache_enabled=1
< ; Sets the directory name where SOAP extension will put cache files.
< soap.wsdl_cache_dir="/tmp"
< ; (time to live) Sets the number of second while cached file will be used
< ; instead of original one.
< soap.wsdl_cache_ttl=86400

In this configuration, I cannot redirect any output data to a file.
 
Flush() after print() or echo() takes no effect.
Only when 'output_handler' is set to 'mb_output_handler'.


Reproduce code:
---------------
$ cat redirect_test.php
#!/usr/local/bin/php -q
<?php
print "Hello, world.\n";
// flush();
?>

Expected result:
----------------
$ ./redirect_test.php > result.txt
$ ls -l result.txt
-rw-r--r--  1 jkawa  jkawa  14 Sep 12 06:32 result.txt
$ cat result.txt
Hello, world.
$

Actual result:
--------------
$ ls -l result.txt
-rw-r--r--  1 jkawa  jkawa   0 Sep 12 06:40 result.txt
$ cat result.txt
$

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-12 07:24 UTC] tony2001@php.net
can't reproduce it.
check if mbstring module is enabled and your code outputs anything without redirection.
 [2004-09-12 09:20 UTC] jkawa at m dot email dot ne dot jp
Without redirection:
$ redirect_test.php
Hello, world.
$

This seems OK.
But in Japanese (EUC-JP), I got incorrect output.
"incorrect" means something wrong, but without redirection and pipe to other, I could not look into this problem further.

P.S.
According to the output from phpinfo(), mbstring extension is certainly enabled.
 [2004-09-12 09:29 UTC] tony2001@php.net
Does it work for you without output_handler = mb_output_handler ?
 [2004-09-12 11:49 UTC] jkawa at m dot email dot ne dot jp
correction:
Without redirection, everything (including Japanese handling) seems OK even if output_hander set to 'mb_output_handler'.

reply:
Without 'output_handler = mb_output_handler', all but auto code conversion works fine.
 [2005-02-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 21:01:27 2024 UTC