Function not returning expected value



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
arrays

// the calling method
function display_states($smarty){

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
file
}

</SNIP>

<SNIP FROM FILE WITH NEEDED ARRAYS>

<?php

require_once BASE . '/config/log.inc.php';

$states = array('Alaska',
'Arkansas',
'Arizona',
'California'); // etc., etc.

$countries = array('United States',
'Canada',
'Afghanistan',
'Albania'); // etc., etc.

logobj($states); // looks good
logobj($countries); // looks good

/**
* get_states
* Fetches a list of states.
*/
function get_states(){
global $states;
return($states);
}

/**
* get_countries
* Fetches a list of countries.
*/
function get_countries(){
global $countries;
return($countries);
}

logobj(get_states()); // looks good
logobj(get_countries()); // looks good

?>

</SNIP>

.



Relevant Pages

  • Re: RAD vs. performance
    ... arrays and lists are iterable containers which, while correct, applies to ... the optimisation phase. ... trade-off in the situations where this abstraction is useful but I think ...
    (comp.lang.misc)
  • Re: Compiler and an interpreter
    ... > Arrays are not more efficient than lists. ... > You should study the STL... ... For really complicate formulae, OCaml will be ...
    (comp.programming)
  • FAQ 4.39 What is the difference between a list and an array?
    ... This message is one of several periodic postings to comp.lang.perl.misc ... from the documentation provided with Perl. ... Subroutines are passed and return lists, ... context, you initialize arrays with lists, and you foreachacross a ...
    (comp.lang.perl.misc)
  • FAQ 4.39 What is the difference between a list and an array?
    ... This message is one of several periodic postings to comp.lang.perl.misc ... from the documentation provided with Perl. ... Subroutines are passed and return lists, ... context, you initialize arrays with lists, and you foreachacross a ...
    (comp.lang.perl.misc)
  • FAQ 4.39 What is the difference between a list and an array?
    ... This message is one of several periodic postings to comp.lang.perl.misc ... from the documentation provided with Perl. ... Subroutines are passed and return lists, ... context, you initialize arrays with lists, and you foreachacross a ...
    (comp.lang.perl.misc)