mardi 26 janvier 2016

Wouldn't the if statement in this PHP function be useless?

I am trying to work on someones code and ran into this.

private function getAttImages($limit, $forumIds = 0, $fidsReverse = false, $topicIds = 0, $membersIds = 0, $order = 'attach_date', $sort = 'desc', $group = null)
    {
        $fids = '';

        if ($forumIds)
        {
            $r = '';
            if ($fidsReverse)
            {
                $r = ' NOT ';
            }

            if (is_array($forumIds))
            {
                $forumIds = implode(',', $forumIds);
            }

            $fids = ' AND forums_topics.forum_id ' . $r . ' IN (' . $forumIds .  ')';
        }

function continues to other things. However, the question is that first if statement if($forumIds) wouldn't it be useless if every time this function is called $forumIds is set to 0 ?

Aucun commentaire:

Enregistrer un commentaire