One of the most recent things to do is to set up several configuration files yourself.
The configuration file itself is a PHP file, configured with an array.
Then because it might contain some configuration of logic, such as
$config = [ "a" => 666, "b" => 777, "x" => "" //可以填 ">","<",">=","<="等等]
Then in the program with this configuration to determine how some of the results of the operation to deal with.
In addition to using
switch($config['x']){ case ">": if(a>b){ } break; case "<": if(a
< code="">
这种笨办法之外,还有什么优雅的实现方式吗?
或者能否推荐相关教程/源码/文章.非常感谢!
Reply content:
One of the most recent things to do is to set up several configuration files yourself.
The configuration file itself is a PHP file, configured with an array.
Then because it might contain some configuration of logic, such as
$config = [ "a" => 666, "b" => 777, "x" => "" //可以填 ">","<",">=","<="等等]
Then in the program with this configuration to determine how some of the results of the operation to deal with.
In addition to using
switch($config['x']){ case ">": if(a>b){ } break; case "<": if(a
< code="">
这种笨办法之外,还有什么优雅的实现方式吗?
或者能否推荐相关教程/源码/文章.非常感谢!
You don't call it a configuration, it's an array of parameters. This is usually the case:
$config = Array (' useableop ' = = ' Array (' > ', ' < ', ' = = ', ' >= ', ' <= '), function do ($param 1, $param 2, $op) {if (! In_array ($op, $config [' Useableop '])) {throw new \ Exception (' invalid operator '); } $param 1 = (int) $param 1; $param 2 = (int) $param 2; Eval ("\ $result = {$param 1} {$op} {$param 2}"); return $result;