Exit and Die as Class Methods

Submitted by pure-php on Mon, 2005-03-14 20:43.

Recently I discovered, that you cannot use exit and die as class methodes. For example

<?php
class test{
    public function exit(){
   }
}
?>

You well get a parser error. Well exit and die are php functions, but waht about time()?

<?php
class test2{
    public function 
time(){
   }
}
?>

Has no parser error.

add new comment
Submitted by Peter Harkins (not verified) on Sat, 2005-03-19 17:55.

exit and die are not functions, they are langauge constructs. As such, they are reserved words. Check the man pages and you'll see a note about it

Submitted by Anonymous (not verified) on Mon, 2005-03-21 08:56.

Thank you, I really diddn't think about that.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Datenschutz | Impressum