2010-05-31 18:29:43 +08:00
|
|
|
$Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $
|
|
|
|
|
|
|
|
|
|
|
|
API adjustment to the old output control code:
|
|
|
|
|
|
|
|
Everything now resides beneath the php_output namespace,
|
|
|
|
and there's an API call for every output handler op.
|
|
|
|
|
|
|
|
Checking output control layers status:
|
|
|
|
// Using OG()
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_get_status();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Starting the default output handler:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_start_ob_buffer(NULL, 0, 1);
|
|
|
|
php_output_start_default();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Starting an user handler by zval:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_start_ob_buffer(zhandler, chunk_size, erase);
|
|
|
|
php_output_start_user(zhandler, chunk_size, flags);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
2017-03-26 15:54:57 +08:00
|
|
|
Starting an internal handler without context:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase);
|
|
|
|
php_output_start_internal(handler_name, handler_name_len, my_php_output_handler_func_t, chunk_size, flags);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Starting an internal handler with context:
|
|
|
|
// not possible with old API
|
|
|
|
php_output_handler *h;
|
2015-12-25 18:13:28 +08:00
|
|
|
h = php_output_handler_create_internal(handler_name, handler_name_len, my_php_output_handler_context_func_t, chunk_size, flags);
|
2010-05-31 18:29:43 +08:00
|
|
|
php_output_handler_set_context(h, my_context, my_context_dtor);
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_start(h);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Testing whether a certain output handler has already been started:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_handler_used("output handler name");
|
|
|
|
php_output_handler_started(handler_name, handler_name_len);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Flushing one output buffer:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_end_ob_buffer(1, 1);
|
|
|
|
php_output_flush();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Flushing all output buffers:
|
|
|
|
// not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_flush_all();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Cleaning one output buffer:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_end_buffer(0, 1);
|
|
|
|
php_output_clean();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Cleaning all output buffers:
|
|
|
|
// not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_clean_all();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Discarding one output buffer:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_end_buffer(0, 0);
|
|
|
|
php_output_discard();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Discarding all output buffers:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_end_buffers(0);
|
|
|
|
php_output_discard_all();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Stopping (and dropping) one output buffer:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_end_buffer(1, 0)
|
|
|
|
php_output_end();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Stopping (and dropping) all output buffers:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_end_buffers(1, 0);
|
|
|
|
php_output_end_all();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Retrieving output buffers contents:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_get_buffer(zstring);
|
|
|
|
php_output_get_contents(zstring);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Retrieving output buffers length:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_get_length(zlength);
|
|
|
|
php_output_get_length(zlength);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Retrieving output buffering level:
|
|
|
|
// OG(nesting_level);
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_get_level();
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Issue a warning because of an output handler conflict:
|
2015-12-25 18:13:28 +08:00
|
|
|
// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name");
|
|
|
|
php_output_handler_conflict(new_handler_name, new_handler_name_len, set_handler_name, set_handler_name_len);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Registering a conflict checking function, which will be checked prior starting the handler:
|
|
|
|
// not possible with old API, unless hardcoding into output.c
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_conflict_register(handler_name, handler_name_len, my_php_output_handler_conflict_check_t);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
|
|
|
|
// not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_reverse_conflict_register(foreign_handler_name, foreign_handler_name_len, my_php_output_handler_conflict_check_t);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Facilitating a context from within an output handler callable with ob_start():
|
|
|
|
// not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Disabling of the output handler by itself:
|
|
|
|
//not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Marking an output handler immutable by itself because of irreversibility of its operation:
|
|
|
|
// not possible with old API
|
2015-12-25 18:13:28 +08:00
|
|
|
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL);
|
2010-05-31 18:29:43 +08:00
|
|
|
|
|
|
|
Restarting the output handler because of a CLEAN operation:
|
|
|
|
// not possible with old API
|
|
|
|
if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }
|
|
|
|
|
|
|
|
Recognizing by the output handler itself if it gets discarded:
|
|
|
|
// not possible with old API
|
|
|
|
if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }
|
|
|
|
|
|
|
|
|
|
|
|
Output handler hooks
|
|
|
|
|
|
|
|
The output handler can change its abilities at runtime. Eg. the gz handler can
|
|
|
|
remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
|
|
|
|
or handlers implemented in C to be used with ob_start() can contain a non-global
|
|
|
|
context:
|
|
|
|
PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
|
|
|
|
pass a void*** pointer as second arg to receive the address of a pointer
|
|
|
|
pointer to the opaque field of the output handler context
|
|
|
|
PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
|
|
|
|
pass a int* pointer as second arg to receive the flags set for the output handler
|
|
|
|
PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
|
|
|
|
pass a int* pointer as second arg to receive the level of this output handler
|
|
|
|
(starts with 0)
|
|
|
|
PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
|
|
|
|
the second arg is ignored; marks the output handler to be neither cleanable
|
|
|
|
nor removable
|
|
|
|
PHP_OUTPUT_HANDLER_HOOK_DISABLE
|
|
|
|
the second arg is ignored; marks the output handler as disabled
|
|
|
|
|
|
|
|
|
|
|
|
Open questions
|
|
|
|
|
|
|
|
Should the userland API be adjusted and unified?
|
|
|
|
|
|
|
|
Many bits of the manual (and very first implementation) do not comply
|
|
|
|
with the behaviour of the current (to be obsoleted) code, thus should
|
|
|
|
the manual or the behaviour be adjusted?
|
|
|
|
|
|
|
|
END
|