You can make a regular constructor private (therefore, it cannot be used from outside the object, as if you were doing a Singleton ) and create a Factory Method .
class MyClass {
private function __construct($input) {
}
public static function factory($input = null) {
if (empty($input)){
return null;
} else {
return new MyClass($input);
}
}
}
Then you must create an instance of the class as follows:
$myClass = MyClass::factory($theInput);
(EDIT: it is now assumed that you are only trying to support PHP5)