473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

output_handler problem

When I set output_handler (either through php.ini our .htaccess) it
does not work with my custom funcions. Why is that?

..htaccess:
will work:
php_value output_handler "ob_gzhandler"

won't work:
php_value output_handler "fwk_output_handler"

php.ini:
will work:
output_handler "ob_gzhandler"

won't work:
output_handler "fwk_output_handler"

I'm checking it through this script:

<?
var_dump(ob_list_handlers());
?>

and all I get is "array(0) { }" when trying to set the handler to any
function other than ob_gzhandler.

Any ideas?

Jul 17 '05 #1
9 5337
Diego Vilar wrote:
When I set output_handler (either through php.ini our .htaccess) it
does not work with my custom funcions. Why is that?

.htaccess:
will work:
php_value output_handler "ob_gzhandler"

won't work:
php_value output_handler "fwk_output_handler"

php.ini:
will work:
output_handler "ob_gzhandler"

won't work:
output_handler "fwk_output_handler"

I'm checking it through this script:

<?
var_dump(ob_list_handlers());
?>

and all I get is "array(0) { }" when trying to set the handler to any
function other than ob_gzhandler.


Yes, this definitely looks like a bug.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2
On 20 Apr 2005 06:42:27 -0700, "Diego Vilar" <di********@gmail.com> wrote:
When I set output_handler (either through php.ini our .htaccess) it
does not work with my custom funcions. Why is that?
Because they haven't been defined yet.
.htaccess:
will work:
php_value output_handler "ob_gzhandler"
ob_gzhandler is a PHP function. So it's already defined.
won't work:
php_value output_handler "fwk_output_handler"
fwk_output_handler is your custom function. Where is it defined? In a PHP
file? But PHP hasn't started reading any files yet, it's still parsing
configuration.
php.ini:
will work:
output_handler "ob_gzhandler"

won't work:
output_handler "fwk_output_handler"

I'm checking it through this script:

<?
var_dump(ob_list_handlers());
?>

and all I get is "array(0) { }" when trying to set the handler to any
function other than ob_gzhandler.

Any ideas?


(a) Use ob_start in whatever include file contains fwk_output_handler; the
function will then be defined since it's parsed the include file, so you can
use it as an output handler.

(b) Define fwk_output_handler in a PHP extension - this is likely to be more
pain than it's worth.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3
Andy Hassall wrote:
On 20 Apr 2005 06:42:27 -0700, "Diego Vilar" <di********@gmail.com> wrote:
<snip>
won't work:
php_value output_handler "fwk_output_handler"


fwk_output_handler is your custom function. Where is it defined? In

a PHP file? But PHP hasn't started reading any files yet, it's still parsing configuration.


The function has to be present in function table is a valid point.
But, the manual has no hint about that. Also, I think, if it works for
ob_start(), it should also work for setting handler in ini. At least
for me, there is much differences.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #4
Yep... The behavior makes sense once the function is not defined yet,
but the output_handler directive should at least be changable through
user scripts so one could set a custom default output_handler without
having to build an extension.

Anyway, thank you guys!

Jul 17 '05 #5
Diego Vilar wrote:
Yep... The behavior makes sense once the function is not defined yet,
but the output_handler directive should at least be changable through
user scripts so one could set a custom default output_handler without
having to build an extension.


Have you reported this behaviour to PHP developers? If not, I'd like
to do it.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #6
No, I haven't reported it. Go ahead and report it if you will.

[ ]'s
Diego

Jul 17 '05 #7
On 26 Apr 2005 10:13:06 -0700, "R. Rajesh Jeba Anbiah"
<ng**********@rediffmail.com> wrote:
Diego Vilar wrote:
Yep... The behavior makes sense once the function is not defined yet,
but the output_handler directive should at least be changable through
user scripts so one could set a custom default output_handler without
having to build an extension.


Have you reported this behaviour to PHP developers? If not, I'd like
to do it.


You can change the output handler in a user script - you call ob_start()
specifying a callback. Not sure what there is to report...

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #8
Yes, we can change the output handler in a user script using
ob_start(), but we cannot define a new default output_handler in a user
script, just as set_error_handler or set_exception_handler would do for
errors and exceptions handlers. That's the point.

Jul 17 '05 #9
Again, just to make it clear so we do not lose the focus here, the
thread is about setting a user-defined function as the DEFAULT handler.

The manual states the following about the directive output_handler:
"You can redirect all of the output of your scripts to a function. For
example, if you set output_handler to mb_output_handler(), character
encoding will be transparently converted to the specified encoding.
Setting any output handler automatically turns on output buffering."

output_handler is a PHP_INI_PERDIR changeable directive. That alone
makes it clear that the function to be used as the default output
handler should be available at the time php.ini and .htaccess are read,
which leads us to the need to either use an already provided function,
or code our own in an extension. But wouldn't that be nice to have a
set_output_handler() function so we could define a user-defined custom
DEFAULT handler?

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.