rfc:autofunc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:autofunc [2011/08/05 00:45] – Spelling, grammar arpad | rfc:autofunc [2011/08/06 11:16] – under discussion tyrael | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2011-08-05 | * Date: 2011-08-05 | ||
* Author: Ferenc Kovacs < | * Author: Ferenc Kovacs < | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 24: | Line 24: | ||
==== Future improvements ==== | ==== Future improvements ==== | ||
- | Notice that currently only functions are proposed, but we could implement autoloading other tokens (T_CONST?) with this interface. | + | Notice that currently only functions are proposed, but we could implement autoloading other tokens (T_DECLARE, |
+ | |||
+ | ==== Examples ==== | ||
+ | <code php> | ||
+ | <? | ||
+ | // old behavior | ||
+ | | ||
+ | function ($name) { | ||
+ | // include the class definition | ||
+ | /* ... */ | ||
+ | } | ||
+ | ); | ||
+ | |||
+ | // autoload functions | ||
+ | | ||
+ | function ($name) { | ||
+ | // include the function definition | ||
+ | /* ... */ | ||
+ | }, | ||
+ | true, | ||
+ | false, | ||
+ | T_FUNCTION | ||
+ | ); | ||
+ | |||
+ | // autoload mixed | ||
+ | | ||
+ | function ($name, $type) { | ||
+ | | ||
+ | case T_CLASS: | ||
+ | /* ... */ | ||
+ | | ||
+ | case T_FUNCTION: | ||
+ | /* ... */ | ||
+ | | ||
+ | } | ||
+ | }, | ||
+ | true, | ||
+ | false, | ||
+ | T_CLASS|T_FUNCTION | ||
+ | ); | ||
+ | </ | ||
==== Patch ==== | ==== Patch ==== |
rfc/autofunc.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1