hi i forgot the code which in a sample class you have to add so that it runs automatically?
is it wakeup or something?
like so:
class something {
function automaticxxx_something_which_runs when class is created()
{
}
}
$s = new something();
-what do i create in the class file so that something runs already after the class is initialized?
i forgot how to name the function name so that it would call it automatically the first function.
If you want a constructor that works in both versions ( although, you should not be coding for php4 as its well past its end-of-life now )
class Foobar
{
function __construct()
{
echo "Hello World!\n";
}
function Foobar()
{
return $this->__construct();
}
}
If you are coding for Just php5 you should get into the habit of specifying visibility explicitly,
class Foobar
{
public function __construct()
{
}
}
(visibility definers didn't exist back in php4)
Should do the trick, with a minor performance loss under php4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With