This article mainly introduces how to dynamically create functions during php runtime, involving the use of php flow statements and create_function functions, for more information about how to dynamically create functions during php running, see the following example. Share it with you for your reference. The specific analysis is as follows:
General language functions must be defined as running, while php supports dynamic function creation at runtime. The following is a simple example: create a function based on different conditions during motion $
<? Phpif (count ($ _ POST)> 0) {$ prepped = create_function ('$ A', 'Return trim ($ _ POST [$ a]);');} elseif (count ($ _ GET)> 0) {$ prepped = create_function ('$ A', 'Return strtoupper ($ _ GET [$ a]);');} else {$ prepped = create_function ('$ A', 'Return false;');} echo $ prepped ('file');?>
I hope this article will help you with php programming.