How can I overwrite built in php functions
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2326835/redefine-built-in-php-functions">Redefine Built in PHP Functions</a>  </p>
</blockquote>



<p>How can I overwrite a built-in PHP function?</p>

<p>I want to overwrite <code>mysql_connection</code> function, function should check if the connection is already opened, just return that connection or else request for a new connection.</p>

<p>I am working with some legacy system, which has 1000's of connections on each page. This reduces the performance of the website and potentially causes bad memory usage.</p>

<p>I want to rework this in such a way that whenever sql connection request is made, system has to check whether the connection is already there or not.</p>

<p>I can't go and change in all the places to replace the connection to common object because system is not written in MVC.</p>

<p>Anybody can help me?</p>
