Hello,
I try to write class which destroy's itself when it gets error. The code should look like this:
class someclass {
[B]function[/B] someclass() { //constructor
$conn = [B]mysql_connect[/B]("srv", "usr", "pass");
[B]if[/B](!$conn)
[B]return FALSE[/B];
}
}
$cl = new someclass();
if/B
echo "Error...";
With no database connection, constructor should return false and class shouldn't initialize. This actually doesn't work. How should I achieve simmilar effect? Can constructor return any value?
Thank you