How to call same name dynamic function from dynamically created files based database inputs
<p>I'm creating a system that would work on call same function names from dynamic created php files. </p>

<p>The file structure is as bellow :  </p>

<ul>
<li>/root/caller.php  //{uses pthreads &amp; process multi simultaniously}</li>
<li>/root/rules/mode1.php</li>
<li>/root/rules/mode2.php</li>
<li>/root/rules/mode{n}.php // goes till n , so unlimited </li>
</ul>

<p>Caller.php reads data from db and calls mode{n} accordingly. Sometimes there are chances to call multiple of rules at a point of time. </p>

<p>Sample of caller.php {written on OOPS}</p>

<pre><code>foreach ($result as $row){
     $mode = $rom-&gt;modeNum;
     include 'rules/mode' . $mode . '.php';
     call_fuction_inside_mode();    
}
</code></pre>

<p>Sample of mode{n}.php {procedural programming}</p>

<pre><code>function call_fuction_inside_mode(){
    //..Custom function depending upon mode{n}
}
</code></pre>

<p>This won't function properly, because caller.php would include same function name again and again. </p>

<p>Please note : </p>

<ul>
<li>I do not want to play with rename function with pecl, as all includes would be required </li>
<li>I have tried calling mode{n}.php by introducing another file "proxy.php"</li>
</ul>

<p>And proxy.php works in below pattern </p>

<p>caller.php -> curl 127.0.0.1/proxy.php?mode={n} -> calls as defined </p>

<p>But this is not efficient way to do this when dealing with >500 requests per sec on micro server. I noticed many requests are killed and there's problem with order number. My target is to achieve this with least memory usage and 100% utilization of provided cpu resources. </p>

<p>I'm confused and so curious to find the solution I should be dealing here. </p>