Posted By

mikael12 on 03/11/11


Tagged

initialize-variables


Versions (?)

Initializing Variables in PHP


 / Published in: PHP
 

URL: http://www.digitalamit.com/article/initvar/2.phtml

Credit goes to Amit Arora

  1. /* initvar()
  2.  * Initialize variables
  3.  */
  4. function initvar() {
  5. foreach( func_get_args() as $v )
  6. {
  7. if( is_array( $v ) )
  8. {
  9. while( list( $key, $value ) = each( $v ) )
  10. {
  11. $GLOBALS[$key] = ( !isset($GLOBALS[$key]) ? $value : $GLOBALS[$key] );
  12. }
  13. }
  14. else
  15. {
  16. $GLOBALS[$v] = ( !isset($GLOBALS[$v]) ? '' : $GLOBALS[$v] );
  17. }
  18. }
  19. }

Report this snippet  

You need to login to post a comment.