Initializing Variables in PHP


/ Published in: PHP
Save to your folder(s)

Credit goes to Amit Arora


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.