Calling __construct() function from __destruct(),
<?php
public function __construct() {
echo "Hi";
}
public function __destruct() {
$this->__construct();
}
?>
will it create infinite loop?
Calling __construct() function from __destruct(),
<?php
public function __construct() {
echo "Hi";
}
public function __destruct() {
$this->__construct();
}
?>
will it create infinite loop?
No, but this will:
class Test {
public function __construct() {
echo "Hi";
}
public function __destruct() {
new Test();
}
}
new Test();
Example: http://ideone.com/94XUg
No, it won't. __construct
is just regular function while called directly instead of using new ClassName;