Created
July 20, 2013 09:28
-
-
Save arraypad/6044439 to your computer and use it in GitHub Desktop.
Make echo & print callable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c | |
index a9ce7de..1a56120 100644 | |
--- a/ext/standard/basic_functions.c | |
+++ b/ext/standard/basic_functions.c | |
@@ -785,6 +785,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_print_r, 0, 0, 1) | |
ZEND_ARG_INFO(0, return) | |
ZEND_END_ARG_INFO() | |
+ZEND_BEGIN_ARG_INFO_EX(arginfo_print, 0, 0, 1) | |
+ ZEND_ARG_INFO(0, var) | |
+ZEND_END_ARG_INFO() | |
+ | |
+ZEND_BEGIN_ARG_INFO_EX(arginfo_echo, 0, 0, 1) | |
+ ZEND_ARG_INFO(0, var) | |
+ZEND_END_ARG_INFO() | |
+ | |
ZEND_BEGIN_ARG_INFO(arginfo_connection_aborted, 0) | |
ZEND_END_ARG_INFO() | |
@@ -2977,6 +2985,8 @@ const zend_function_entry basic_functions[] = { /* {{{ */ | |
PHP_FE(var_export, arginfo_var_export) | |
PHP_FE(debug_zval_dump, arginfo_debug_zval_dump) | |
PHP_FE(print_r, arginfo_print_r) | |
+ PHP_FE(print, arginfo_print) | |
+ PHP_FE(echo, arginfo_echo) | |
PHP_FE(memory_get_usage, arginfo_memory_get_usage) | |
PHP_FE(memory_get_peak_usage, arginfo_memory_get_peak_usage) | |
@@ -5513,6 +5523,40 @@ PHP_FUNCTION(print_r) | |
} | |
/* }}} */ | |
+/* {{{ proto mixed print(mixed var) | |
+ Prints out the specified variable */ | |
+PHP_FUNCTION(print) | |
+{ | |
+ zval *var; | |
+ | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &var) == FAILURE) { | |
+ return; | |
+ } | |
+ | |
+ zend_print_variable(var); | |
+ RETURN_TRUE; | |
+} | |
+/* }}} */ | |
+ | |
+/* {{{ proto mixed echo(mixed var [, ...]) | |
+ Prints out the specified variable(s) */ | |
+PHP_FUNCTION(echo) | |
+{ | |
+ zval ***args; | |
+ int num_args, i; | |
+ | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &num_args) == FAILURE) { | |
+ return; | |
+ } | |
+ | |
+ for (i = 0; i < num_args; i++) { | |
+ zend_print_variable(*args[i]); | |
+ } | |
+ | |
+ efree(args); | |
+} | |
+/* }}} */ | |
+ | |
/* {{{ proto int connection_aborted(void) | |
Returns true if client disconnected */ | |
PHP_FUNCTION(connection_aborted) | |
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h | |
index 7327f7d..01738c6 100644 | |
--- a/ext/standard/basic_functions.h | |
+++ b/ext/standard/basic_functions.h | |
@@ -101,6 +101,8 @@ PHP_FUNCTION(set_include_path); | |
PHP_FUNCTION(restore_include_path); | |
PHP_FUNCTION(print_r); | |
+PHP_FUNCTION(print); | |
+PHP_FUNCTION(echo); | |
PHP_FUNCTION(fprintf); | |
PHP_FUNCTION(vfprintf); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment