Joyride Posted May 23, 2007 Report Share Posted May 23, 2007 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 More sharing options...
bubu Posted May 23, 2007 Report Share Posted May 23, 2007 isset($GLOBALS[$$name]) ? Cik man izskatās, tā funkcija nemaz nevar iztikt neaiztiekot gobālos mainīgos - tāda ir viņas būtība - aiztikt tos globāļus. Link to comment Share on other sites More sharing options...
andrisp Posted May 23, 2007 Report Share Posted May 23, 2007 Šīnī gadijumā nesaskatu nekādus drawbackus tam globālajam mainīgajam. Link to comment Share on other sites More sharing options...
Recommended Posts