title: How to compare two functions in PHP?
body: <p>What would be the best way to check if two functions (not the output, as this might return false positives) are identical? A simple check does not do the trick.</p>
  
  <p>The code below is an abstract example, real world use case might be comparing provided closures in a function to prevent doing the same thing twice.</p>
  
  <pre class="lang-php prettyprint-override"><code>$function1 = function ($one, $two) {
      return $one + $two;
  };
  
  $function2 = function ($one, $two) {
      return $one + $two;
  };
  
  $same = ($function1 == $function2); // false
  </code></pre>