Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Function not returning expected value
May 29, 2005, 3:41 pm
rate this thread
I have a php file that contains a couple of arrays used for
state/country pull-down lists. I have two global arrays and an accessor
method for each. I have some simple logging methods, so I know a little
bit about what I'm getting back. When I try to get the arrays from
another file using the accessor methods, I get no array back. Within
the file that contains the arrays, I can access them by global name and
also by the accessor methods. Any ideas why I cannot access the arrays
from another file? Code below.
<SNIP FROM CALLING METHOD>
require_once BASE . '/config/formfields.inc.php'; // file with needed
// the calling method
logobj(function_exists(get_states)); // returning True/1
$s = get_states();
logobj($s); // no love here
logobj(BASE . '/config/formfields.inc.php'); // it's the right
<SNIP FROM FILE WITH NEEDED ARRAYS>
require_once BASE . '/config/log.inc.php';
$states = array('Alaska',
'California'); // etc., etc.
$countries = array('United States',
'Albania'); // etc., etc.
logobj($states); // looks good
logobj($countries); // looks good
* Fetches a list of states.
* Fetches a list of countries.
logobj(get_states()); // looks good
logobj(get_countries()); // looks good
Re: Function not returning expected value
That's a good point. I use a "smarty" template, and when I look at the
contents I see this in the member variables:
[_tpl_vars] => Array
[SCRIPT_NAME] => /drc2/register.php
Could an eval statement be creating the "states" var here and
clobbering my initial states reference?
I will experiment and post my results....