note 58203 added to function.include

From: Date: Thu, 27 Oct 2005 12:16:43 +0000
Subject: note 58203 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-97687@lists.php.net to get a copy of this message
previouse example doesn't work :( its always writes eval()'d error. (am i stupid, maybe?) i've tryed some different variations and have found (i think) a problem with different (in global) types of variables. i don't think that everyone need to include ALL vars from $_GLOBAL... in my templates i only use variables with prefix $XT_...bla-bla-bla so i've "cut" your example to this: //============================================= foreach(array_keys($GLOBALS) as $index){ $value=($GLOBALS[$index])?$GLOBALS[$index]:''; if(substr($index,0,2)=='XT'){ // here you can change to anything you want eval("global \$$index;"); } } //============================================= this is work ;) (PHP 4.3.10) p.s. while executing this example on P4 2.6 GHz difference beetween with checking substr() function is faster (0.005-0.01 sec) than without. ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58203 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58203&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58203&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97687) next »