rfc:autofunc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:autofunc [2011/08/05 00:45] – Spelling, grammar arpadrfc:autofunc [2011/08/06 11:16] – under discussion tyrael
Line 3: Line 3:
   * Date: 2011-08-05   * Date: 2011-08-05
   * Author: Ferenc Kovacs <tyra3l@gmail.com>   * Author: Ferenc Kovacs <tyra3l@gmail.com>
-  * Status: Draft+  * Status: Under Discussion
   * First Published at: https://wiki.php.net/rfc/autofunc   * First Published at: https://wiki.php.net/rfc/autofunc
  
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, T_CONST, etc.) with this interface. 
 + 
 +==== Examples ==== 
 +<code php> 
 + <?php 
 + // old behavior 
 + spl_autoload_register( 
 +  function ($name) { 
 +   // include the class definition 
 +   /* ... */ 
 +  } 
 + ); 
 + 
 + // autoload functions 
 + spl_autoload_register( 
 +  function ($name) { 
 +   // include the function definition 
 +   /* ... */ 
 +  }, 
 +  true, 
 +  false, 
 +  T_FUNCTION 
 + ); 
 + 
 + // autoload mixed 
 + spl_autoload_register( 
 +  function ($name, $type) { 
 +   switch($type){ 
 +    case T_CLASS: 
 +     /* ... */ 
 +     break; 
 +    case T_FUNCTION: 
 +     /* ... */ 
 +     break;       
 +   } 
 +  }, 
 +  true, 
 +  false, 
 +  T_CLASS|T_FUNCTION 
 + ); 
 +</code> 
  
 ==== Patch ==== ==== Patch ====
rfc/autofunc.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1