Jump to content
php.lv forumi

Global variables


Joyride

Recommended Posts

Ka varetu parrakstit so funkciju bez mainiga iesauksanas ar global palidzibu?

 

   
  define('TYPE_STRING', 'string');
  define('TYPE_INTEGER', 'integer');
  define('TYPE_DOUBLE', 'double');

  function get_var($name, $def_value, $type = TYPE_STRING, $validation = '') {
  global $$name;
  if(isset($$name)) {
	 return $$name;
  }
  else {
	 return $def_value;
  }
  }

  $unset = 'set';
  echo get_var('unset', 'default', TYPE_STRING);

Link to comment
Share on other sites

×
×
  • Create New...