Edit report at https://bugs.php.net/bug.php?id=60098&edit=1

 ID:                 60098
 Comment by:         dagguh at gmail dot com
 Reported by:        syntaqx at gmail dot com
 Summary:            Static constructors, or static intializers
 Status:             Open
 Type:               Feature/Change Request
 Package:            SPL related
 Operating System:   All
 PHP Version:        5.4.0beta1
 Block user comment: N
 Private report:     N

 New Comment:

You mean something like Static Initialization Blocks from Java? Yeah, I'd like 
to 
see them too.

http://download.oracle.com/javase/tutorial/java/javaOO/initial.html


Previous Comments:
------------------------------------------------------------------------
[2011-10-19 17:48:18] syntaqx at gmail dot com

Description:
------------
I've noticed a fairly large trend in a lot of php frameworks, as well as in my 
own code, and I was curious about whether this is planned, the reasons as to 
why 
it might not be, or if it has even been brought up.

I've tried to find any other requests about this, but haven't been very 
successful.

Basically, my request is this:
When a class comes into existence (whether the code is in the file you're 
currently in, or you're including it), a static constructor (a common method 
for 
it is "::init") is called. This is called only once, the first time the class 
exists, and would act as a protected method (allowing parent-child objects to 
call it incase of a class reset?).

This would be pretty awesome, but I don't know if it's practical, or what all 
your thoughts might have been as I'm sure plenty of you have seen it floating 
around.

Thanks a bunch for taking the time to read my request, I'm excited to hear what 
you think :)



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60098&edit=1

Reply via email to