& Amp; variable reference PHPcodefunction_is_numerice ($ var) {if (is_numeric ($ var) {returntrue ;}}$ var123456; _ is_numerice ($ var ); _ is_numerice (& amp; $ var); use & amp; here to check whether the variable is referenced
PHP code
Function _ is_numerice ($ var) {if (is_numeric ($ var) {return true ;}$ var = 123456; _ is_numerice ($ var ); _ is_numerice (& $ var); // used here &, does it increase efficiency?
------ Solution --------------------
This increases efficiency.
PHP code
Function _ is_numerice (& $ var)
------ Solution --------------------
There is almost no difference in the efficiency of such a small variable reference. When the data volume is large, it may increase.
Why is there no direct is_numeric ($ var. How can I write another function.
------ Solution --------------------
1. because only the transfer mode of variables is changed and the operation logic is not changed, only the memory usage is considered.
PHP code
Function _ is_numerice ($ var) {if (is_numeric ($ var) {echo memory_get_usage (), PHP_EOL; return true ;}$ var = 123456; echo memory_get_usage (), PHP_EOL; _ is_numerice ($ var); echo memory_get_usage (), PHP_EOL; _ is_numerice (& $ var); // is it more efficient to use & here?
------ Solution --------------------
Discussion
(⊙ O ⊙ ).... Yes. is_numerice is just a simple example. There are a lot of analysis code in it.
What is the difference between function _ is_numerice (& $ var) and directly using _ is_numerice (& $ var?