Permalink
Switch branches/tags
yaf-2.1.0 xmlrpc_epi_0_51_merge_pt php5_5_0 php4 php_ibase_before_split oci8-1.4.3 oci8-1.4.0 init help dev before-sapi-split ZO_B1 ZEND_OPTIMIZER_B1 SQLITE_4_3_20041227 SPL_ALPHA SAFEGUARD_3_0_BETA1_RC1_26062002 RETURN_REF_BP RELEASE_2_0_2 RELEASE_2_0_1 RELEASE_2_0_0 RELEASE_2_0_0b1 RELEASE_2_0_0a2 RELEASE_2_0_0a1 RELEASE_2_0_0RC1 RELEASE_1_5 RELEASE_1_4 RELEASE_1_3_5 RELEASE_1_3_1 RELEASE_1_3 RELEASE_1_3b6 RELEASE_1_3b3 RELEASE_1_3b2 RELEASE_1_2_5 RELEASE_1_2_4 RELEASE_1_2_3 RELEASE_1_2_2 RELEASE_1_2_1 RELEASE_1_2_0 RELEASE_1_2 RELEASE_1_2b5 RELEASE_1_1_1 RELEASE_1_1_0 RELEASE_1_1 RELEASE_1_0_4 RELEASE_1_0_3 RELEASE_1_0_2 RELEASE_1_0_1 RELEASE_1_0_0RC1 RELEASE_1_0 RELEASE_1_0b3 RELEASE_1_0b2 RELEASE_1_0b1 RELEASE_1_0RC2 RELEASE_1_0RC1 RELEASE_0_91 RELEASE_0_90 RELEASE_0_11 RELEASE_0_10 RELEASE_0_9_4 RELEASE_0_9_3 RELEASE_0_9_2 RELEASE_0_9_1 RELEASE_0_9_0 RELEASE_0_9 RELEASE_0_9b RELEASE_0_7 RELEASE_0_6 RELEASE_0_5_3 RELEASE_0_5_2 RELEASE_0_5 RELEASE_0_4 RELEASE_0_3 RELEASE_0_2_4 RELEASE_0_2_3 RELEASE_0_2_2 RELEASE_0_2_1 RELEASE_0_2_0 RELEASE_0_2 RELEASE_0_1_1 RELEASE_0_1 PRE_ZEND_VM_DISPATCH_PATCH PRE_USED_RETURN_VALUE_PATCH PRE_TSRM_MERGE_PATCH PRE_SUBST_Z_MACROS PRE_RETURN_REF_PATCH PRE_RETURN_REF_MERGE PRE_PARAMETER_PARSING_API PRE_NEW_VM_GEN_PATCH PRE_NEW_OCI8_EXTENSION PRE_METHOD_DEREFERENCE_PATCH PRE_METHOD_CALL_SEPERATE_FIX_PATCH PRE_LIBZEND_TO_ZEND PRE_LIBMYSQL_REVERT PRE_ISSET_TYPE PRE_ISSET_PATCH PRE_GRANULAR_GARBAGE_FIX PRE_FUNC_RETURNS_OBJECT_PATCH PRE_FILE_COMPILE_API_CHANGE PRE_FETCH_READ_PATCH PRE_ENGINE2_SPLIT
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
143 lines (106 sloc) 5.45 KB
$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()
php_output_get_status(TSRMLS_C);
Starting the default output handler:
// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
php_output_start_default(TSRMLS_C);
Starting an user handler by zval:
// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);
Starting an internal handler whithout context:
// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
php_output_start_internal(handler_name, handler_name_len, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);
Starting an internal handler with context:
// not possible with old API
php_output_handler *h;
h = php_output_handler_create_internal(handler_name, handler_name_len, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
php_output_handler_set_context(h, my_context, my_context_dtor);
php_output_handler_start(h TSRMLS_CC);
Testing whether a certain output handler has already been started:
// php_ob_handler_used("output handler name" TSRMLS_CC);
php_output_handler_started(handler_name, handler_name_len TSRMLS_CC);
Flushing one output buffer:
// php_ob_end_buffer(1, 1 TSRMLS_CC);
php_output_flush(TSRMLS_C);
Flushing all output buffers:
// not possible with old API
php_output_flush_all(TSRMLS_C);
Cleaning one output buffer:
// php_ob_end_buffer(0, 1 TSRMLS_CC);
php_output_clean(TSRMLS_C);
Cleaning all output buffers:
// not possible with old API
php_output_clean_all(TSRMLS_C);
Discarding one output buffer:
// php_ob_end_buffer(0, 0 TSRMLS_CC);
php_output_discard(TSRMLS_C);
Discarding all output buffers:
// php_ob_end_buffers(0 TSRMLS_CC);
php_output_discard_all(TSRMLS_C);
Stopping (and dropping) one output buffer:
// php_ob_end_buffer(1, 0 TSRMLS_CC)
php_output_end(TSRMLS_C);
Stopping (and dropping) all output buffers:
// php_ob_end_buffers(1, 0 TSRMLS_CC);
php_output_end_all(TSRMLS_C);
Retrieving output buffers contents:
// php_ob_get_buffer(zstring TSRMLS_CC);
php_output_get_contents(zstring TSRMLS_CC);
Retrieving output buffers length:
// php_ob_get_length(zlength TSRMLS_CC);
php_output_get_length(zlength TSRMLS_CC);
Retrieving output buffering level:
// OG(nesting_level);
php_output_get_level(TSRMLS_C);
Issue a warning because of an output handler conflict:
// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
php_output_handler_conflict(new_handler_name, new_handler_name_len, set_handler_name, set_handler_name_len TSRMLS_CC);
Registering a conflict checking function, which will be checked prior starting the handler:
// not possible with old API, unless hardcoding into output.c
php_output_handler_conflict_register(handler_name, handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
// not possible with old API
php_output_handler_reverse_conflict_register(foreign_handler_name, foreign_handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
Facilitating a context from within an output handler callable with ob_start():
// not possible with old API
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);
Disabling of the output handler by itself:
//not possible with old API
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);
Marking an output handler immutable by itself because of irreversibility of its operation:
// not possible with old API
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
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