fork(3) download
  1. <?php
  2.  
  3. class A {
  4. private function __construct () {
  5. echo "Created!\n";
  6. }
  7. public static function attemptToCreate ($should_it_succeed) {
  8. if ($should_it_succeed) {
  9. return new A();
  10. }
  11. return false;
  12. }
  13. }
  14.  
  15. var_dump(A::attemptToCreate(0));
  16. var_dump(A::attemptToCreate(1));
  17.  
  18. //! new A(); - gives error
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
bool(false)
Created!
object(A)#1 (0) {
}