You are here: Re: [PHP] manipulating constant name as string « PHP « IT news, forums, messages
Re: [PHP] manipulating constant name as string

Posted by Tom Rogers on 01/02/06 05:01

Hi,

Monday, January 2, 2006, 4:37:17 AM, you wrote:
DG> Hello

DG> I am trying to access the constant name as string and not the constant
DG> contents. For example,

DG> define('myconst', 'const text 1');

DG> $myArray = array()

DG> myArray['myconst'] = "this is it"
DG> etc.

DG> $xmltext="";
DG> foreach ($myArray as $key => $val) {
DG> echo "$key = $val\n\n";
DG> $xmltext .= "$xmltext = $xmltext . "<$key> $val </$key>";
DG> }

DG> Unfortunately, $key within the string concatenation is translated into
DG> the constant value. However, for the echo statement, then $key constant
DG> name is displayed. Is there a way to keep the constant name rather its
DG> value when manipulating it as a string?

DG> thanks,

DG> Daniel

drop the single quotes to use the constant:

myArray[myconst] = "this is it"
--
regards,
Tom

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация