Evaluating defines

From: Date: Wed, 04 Jun 2003 11:46:15 +0000
Subject: Evaluating defines
Groups: php.general 
Request: Send a blank email to php-general+get-150245@lists.php.net to get a copy of this message
Hi, i have a template system where the user can define some multilangual defines, identified by {Label[My_define_name]} in the template. Its one of the way i figured to go around the probleme of multilangual websites. Ok the function below parse the template and gets all the {Lang[My_deifne]} and the My_define. My probleme is that i need to return the value of my define and not its name. My eval doesnt seem to work. Any body as a sugestion , or a better way to do this without passing by eval . Thanks -------------- function ParseLabel(){ preg_match_all("/\{(Label)*\[([-A-Za-z_]*)]\}/",$this->GetTemplateString(),$out); $j = count($out[2]); for($i=0;$i<$j;$i++){ if(!defined($out[2][$i])){ $error_message = str_replace("{tag}", $out[0][$i], NoMatchingLangLiteral); $this->_err->ErrorHandler(NoMatchingLangLiteralErrorNumber,$error_message,__FILE__,__LINE__); }else{ $to_replace[] = $out[0][$i]; ---------> $replace_by[] = eval("echo \$out[2][$i];"); <-------- } } $this->ReplaceTag($to_replace,$replace_by); } -----------

« previous php.general (#150245) next »