php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27896 eval
Submitted: 2004-04-07 00:06 UTC Modified: 2004-04-07 01:23 UTC
From: jesse at erieonline dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.5 OS: WinXP / FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jesse at erieonline dot com
New email:
PHP Version: OS:

 

 [2004-04-07 00:06 UTC] jesse at erieonline dot com
Description:
------------
I have a variable called $config['sold_email_winner_message'], which has an emal message template stored in the variable.  Within this email message, i have information like:

Dear $winner_info[first_name] $winner_info[last_name],

Congrates...

I use eval to evaluate the string.  One thing I noticed is that the following doesn't work

$winner_info['first_name'] $winner_info['last_name'], but $winner_info[first_name] $winner_info[last_name] does work.

One would think that these should be interchangeable.

Reproduce code:
---------------
$winner_info = array ('first_name' => "First", 'last_name' => "Last");

This doesn't work:

$config['sold_email_winner_message'] = "Dear $winner_info['first_name'] $winner_info['last_name']";
eval ("\$config[sold_email_winner_message] = \"$config[sold_email_winner_message]\";");

This does work:
$config['sold_email_winner_message'] = "Dear $winner_info[first_name] $winner_info[last_name]";
eval ("\$config[sold_email_winner_message] = \"$config[sold_email_winner_message]\";");

Expected result:
----------------
This will print the following:
Dear First Last

Actual result:
--------------
This will print the following:
Dear $winner_info['first_name'] $winner_info['last_name']

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-07 01:23 UTC] pollita@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 26 00:00:01 2025 UTC