Monday, June 23, 2008

PHP Segmentation Fault

I ran around this problem a couple of times, and recently i spent more than 20 mins trying to figure out why my php page was seg faulting. Well now I'm going to document it.

To make it simple, this code will give you a seg fault:

class A
{
function __construct()
{
new B;
}
}

class B extends A
{

}

new A;


Don't create new objects from classes that inherit from the class you are creating the object. Yes sounds confusing, and probably it makes no sense but i think the code above is enough to explain it.

No comments: