NYCPHP Meetup

NYPHP.org

[nycphp-talk] undefined function in class method that suddenly exists

Phillip Powell phillip.powell at adnet-sys.com
Mon Apr 26 15:05:33 EDT 2004


[PHP]
/**
 * Class for performing the search
 *
 * @author Phil Powell
 * @version 1.0.0
 * @package IMAGE_CATALOG
 * @see db_action.inc.php:DBActionPerformer
 */
class SearchPerformer extends DBActionPerformer {


    /**
      * This static method will determine if the element passed here (by 
the value of $elementName as parameter) has a value, even if it is an array
      *
      * @access private
      * @param mixed $elementName
      * @param mixed $section
      * @return boolean
      */
    function &isElement($elementName, $section) {            // STATIC 
BOOLEAN METHOD
        global ${$elementName};        // PASS VALUE HERE
        switch ($section) {
         
         case 'image':                // SPECIFIC IMAGE-RELATED HANDLING 
OF $this->formFieldsArray
          
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------
            Also note that you have to call Accepter "statically" 
(class-level) instead of instantiating the object, otherwise,
            you will be instantiating $this->validate(), causing a n^2 
loop construct of an unnecessary validation call, which is
            way bad!  However, the property cannot be called directly in 
PHP versions 4 due to language constraints (if someone knows how
            let *ME* know!) so you have to use a static getter method to 
retrieve it
          
-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
          print_r(is_array(${$elementName})); print_r(" "); 
print_r(@sizeof(array_values(${$elementName}))); print_r(' '); 
print_r(${$elementName}); print_r(" "); echo 
Accepter::getNullExemptionArray($section, $elementName); print_r("<P>");
          if (is_array(${$elementName}) && 
@sizeof(array_values(${$elementName})) > 0) {
           return true;
          } elseif (${$elementName} && ${$elementName} !== 
Accepter::getNullExemptionArray($section, $elementName)) {
           return true;
          } else {
           return false;
          }
          break;
       
          default: // DO NOTHING FOR NOW
          break;
        }
    }

}
[/PHP]

The following method in the class function:

[PHP]
print_r(is_array(${$elementName})); print_r(" "); 
print_r(@sizeof(array_values(${$elementName}))); print_r(' '); 
print_r(${$elementName}); print_r(" "); echo 
Accepter::getNullExemptionArray($section, $elementName); print_r("<P>");
[/PHP]

Produces this error:

[Quote]
Fatal error: Call to undefined function: getnullexemptionarray() in 
/www/html/mu-spin/image_catalog/include/search_action.inc.php on line 267
[/Quote]

However, if I comment out line 267 and you follow *THIS* line:

[PHP]
      } elseif (${$elementName} && ${$elementName} !== 
Accepter::getNullExemptionArray($section, $elementName)) {
           return true;
[/PHP]

Then the class method works w/o a single fatal error whatsoever, and I 
even verified with the following:

[PHP]print_r("elementName = $elementName = ${$elementName}<P>");[/PHP]

To verify if ${$elementName} exists thus possibly meeting (or not 
meeting) the conditon. 

So now, why is it that on one line, Accepter::getNullExemptionArray() 
produces an "undefined function" fatal error, but in another line, same 
class, same method, it produces no errors at all???

What am I missing this time?

Phil

-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
ADNET Systems., Inc.
11260 Roger Bacon Drive Suite 403
Reston, VA  20191
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list