title: Instantiating an object within its own class
body: <p>I was trying to figure out if I can instantiate a class within its own constructor and I came across this:</p>
  
  <p><a href="https://stackoverflow.com/questions/5186214/why-can-you-instantiate-a-class-within-its-definition">Why Can You Instantiate a Class within its Definition?</a>.</p>
  
  <p>Then I tried the same thing in PHP:</p>
  
  <pre><code>Class someClass {
   function __construct() {
    $objNew = new someClass();
    $objNew-&gt;doit();
   }
  
    function doit() {
     echo "Do it man!\n";
    }
  }
  
  $oNew = new someClass();
  </code></pre>
  
  <p>Everytime I tried to run this I got a "Segmentation Fault" error.....
  With reference to the above code and even the link posted above, I want to think that instantiating a class within its own constructor would cause an infinite number of objects to get created (until the server crashes, of course!).....any thoughts on what is going on above? Why is it ok to do this in Java and (perhaps) not in PHP?</p>