My apologies for assuming too much of the variable names.  Thank you for
correcting me.

Your response has caused me good confusion though.  If I remove the ${...}
notation I get quite a different output (specifically, there's no output).
Are you sure the parser ignores it?

This is the code I suggested WITHOUT the ${...} that returns nothing.
$test_name="ta_dah";
define("constant_name","test_name");
$constant_value=$constant_name;
echo $constant_value;

And I wonder too if my odd usage of ${...} notation is improper in
variables.  When I want to create a dynamically named variable (as opposed
to my off-topic constant example), I use:

${$variable_name}="value";
or even
${"fixed_string".$variable_name}="value";

I hope I'm not going against sane practices in doing so.

On Wed, 28 Mar 2001, Geoff Caplan wrote:

> Art,
>
> Thanks for the suggestion, but I think there is a flaw in your
> solution.
>
> The original issue was how to get at the value of a constant where the
> $constant_name is dynamically created as a variable.
>
> In your solution you have defined constant_name as a constant!
> So when you assign it, it does, of course, behave as a constant.
>
> I don't think the ${...} notation is doing anything - it is just being
> ignored by the parser so far as I can see ...
>
> AW> $test_name="ta_dah";
> AW> define("constant_name","test_name");
> AW> $constant_value=${constant_name};
>
> Geoff Caplan
>
>

-- 
March 27, 2001: Tuesday is a scissors.
  Opposed blades make a finer cut.
      --http://artwells.com/oracula/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to