On Mon, 04 Mar 2019 02:23:46, Peter Kokot wrote:
Now, interesting is that in bash and some langs (where the main environment is CLI), there is by default newline echoed. In PHP and other languages there isn't. Changing default functionality of echo in PHP is like changing left-hand traffic countries to use right-hand traffic. A new function name would be needed for that. You can start with creating an extension for this.
I think the best option is a new function like "puts" or "posix_puts". I looked into this but im having trouble. i started with "var_dump" because that does produce a newline by default [1]: php_printf("%sbool(false)\n", COMMON); new function would be most similar to "print", so i went to look at that code, but it seems "print" uses "echo" internally [2]: opline = zend_emit_op(NULL, ZEND_ECHO, &expr_node, NULL); so then i went to look at "echo" code. however i cant actually seen to find where that is defined, as the PHP codebase is... byzantine. it seems ZEND_ECHO is handled by "zend_write" [3]: zend_write(ZSTR_VAL(str), ZSTR_LEN(str)); which is handled by "write_function" [4]: zend_write = (zend_write_func_t) utility_functions->write_function; which is handled by "php_output_write" [5]: zuf.write_function = php_output_write; which is handled by "php_output_op" [6]: php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len); which is handled by "ub_write" [7]: sapi_module.ub_write(context.out.data, context.out.used); which is handled by "orig_ub_write" [8]: sapi_module.ub_write = orig_ub_write; which is handled by... "ub_write"? [9]: size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write; it seems like a circular definition. surely i am getting something wrong, and is it really need to go 8 levels of abstraction to write to standard output? [1] https://github.com/php/php-src/blob/df57395/ext/standard/var.c#L109 [2] https://github.com/php/php-src/blob/df57395/Zend/zend_compile.c#L7361 [3] https://github.com/php/php-src/blob/df57395/Zend/zend_vm_def.h#L1584 [4] https://github.com/php/php-src/blob/df57395/Zend/zend.c#L810 [5] https://github.com/php/php-src/blob/df57395/main/main.c#L2140 [6] https://github.com/php/php-src/blob/df57395/main/output.c#L255 [7] https://github.com/php/php-src/blob/df57395/main/output.c#L1076 [8] https://github.com/php/php-src/blob/df57395/ext/opcache/ZendAccelerator.c#L4211 [9] https://github.com/php/php-src/blob/df57395/ext/opcache/ZendAccelerator.c#L4126 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php