How to create loop templates in php

后端 未结 4 1478
清酒与你
清酒与你 2021-02-19 00:56

As we can define loop templates in C++, for making coding shorter:

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )

Is there any way to d

4条回答
  •  太阳男子
    2021-02-19 01:28

    How about something like:

    function my_macro($a, $b, $c) {
      $args = func_get_args();
      array_shift($args);
      array_shift($args);
      array_shift($args);
    
      return call_user_func_array("something_horrifically_long_involving_{$a}_{$b}_and_{$c}", $args);
    }
    

提交回复
热议问题