This article mainly introduces the PHP general return value of the setting method of the detailed, interested in the friend's reference, I hope to be helpful to everyone.
Encountered a good PHP code. Record it.
When you write PHP code, you often encounter the need to return the value of the situation, you can set the return value of the uniform format.
Here's a good example.
Configuration Class Return.conf.php
<?phpdefine ("Return_val", "Return Array" (' Code ' = 0, ' msg ' = ' = ', ' data ' = '); "); Define ("Return_success", 0); Define ("Return_runtime_err", 1); Define ("Return_file_not_exist", 2); class returnconf{public static function Commonreturn () { return eval (return_val); } }? >
testing, using test.php
<?phprequire_once ("Return.conf.php"), function Get_file_line ($filename) { $result = Returnconf::commonreturn (); $cmd = "Wc-l $filename | awk ' {print '} '; EXEC ($cmd, $output, $code); if (return_success!== $code) { $result [' code '] = Return_runtime_err; $result [' msg '] = "exec $cmd err"; return $result; } $result [' data '] = $output [0]; return $result;} Print_r (Get_file_line ("test.php"));? >
The above is the whole content of this article, I hope that everyone's study has helped.