Function not returning expected value
- From: jeff@xxxxxxxx
- Date: 29 May 2005 10:41:38 -0700
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>
.
- Follow-Ups:
- Re: Function not returning expected value
- From: Janwillem Borleffs
- Re: Function not returning expected value
- Prev by Date: Re: ssh or ftp for writing scripts?
- Next by Date: Re: NOT EXISTS syntax problem
- Previous by thread: ssh or ftp for writing scripts?
- Next by thread: Re: Function not returning expected value
- Index(es):
Relevant Pages
|