A comparison result for a class of semilinear elliptic equations