Edit report at https://bugs.php.net/bug.php?id=60098&edit=1
ID: 60098 Comment by: mkutschker-php at yahoo 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: I think that a magic method named __init() would be a PHP way to go. Previous Comments: ------------------------------------------------------------------------ [2011-10-27 14:56:38] syntaq at gmail dot com That seems to be what I'm requesting. Does that seem like something that could be implemented into PHP fairly easily? ------------------------------------------------------------------------ [2011-10-24 16:30:02] dagguh at gmail dot com 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 ------------------------------------------------------------------------ [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