PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
class whateverClass {
//PHP5's constructor
function __construct() {
//
}
//PHP4's constructor
function whateverClass() {
$this->__construct(); //Loop back into the PHP5 one
}
}
I don't understand why you would? Why would you use PHP 5 object syntax in PHP 4 application. PHP 5 should pick up on old constructors just fine. Did I miss something?
Well I see how it allows the same script to run both places; but you still can take advantage of PHP5's features if you're trying for compatability with PHP4... so you still can use well-named super-class constuctors, etc...
For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.
For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.