Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Example code:

<?php
class MyClass {
    public $bar = array('a', 'b', 'c');
    public function getBar() {return $this->bar;}

    public function execute(array $fooArray) {
        foreach ($fooArray as $foo) {
            echo $foo.":".$this->checkBar($foo, $this->getBar())." ";// PASSED IN//
            //echo $foo.":".$this->checkBar($foo)." ";// RETRIEVED //
        }
    }

    // PASSED IN //
    public function checkBar($foo, array $fooCheck) {
        return in_array($foo, $fooCheck);
    }

    // RETRIEVED //
    /*public function checkBar($foo) {
         $fooCheck = $this->getBar();
         return in_array($foo, $fooCheck);
    }*/
}

$someClass = new MyClass();
$someClass->execute(array('a','f','c','g'));
?>

Are there any performance considerations to passing $fooCheck in as a variable into checkBar vs having MyClass::checkBar() handle calling the function itself?

share|improve this question
Nope, it's all good. – Yannis Nov 12 '11 at 3:47

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.