1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What is the purpose of $forum_id on its own line?

Discussion in 'XenForo Development Discussions' started by LPH, Jun 11, 2013.

  1. LPH

    LPH Well-Known Member

    In looking at this code, why is $forum_id sitting in a line all by itself?

    Sorry to be daft but it looks strange to me.

    Should it be forum_id=' ' or something else?

      if($post->post_type == 'post')
    //get the category for this post
    $categories get_the_category($post->ID);

    //lookup what forum ID posts of this category go in

    $forum_id_array $XF->options['xf_category_forum_id'];

    $categories as $category)
    $slug $category->slug;
    $forum_id_array[$slug]) && $forum_id_array[$slug] != 0)
    $forum_id $forum_id_array[$slug];

    $forum_id $forum_id_array['default'];

        else ... 
    blah blah more and more ... blah ..
  2. Jeremy P

    Jeremy P Well-Known Member

    Judging by the code you could remove it with no ill effects. Not sure why it's there, seems like some left over code that should've been removed.
  3. LPH

    LPH Well-Known Member

    OK. I'm going to comment it out on a test environment and see what happens. Thank you. I just didn't know if there was a purpose that I didn't understand.
  4. EasyTarget

    EasyTarget Well-Known Member

    By declaring the variable you are forcing the php interpreter to assign a pointer, and to set its value to NULL. It is the equivalent of $forum_id = NULL;

    It is done, so the subsequent statement of !isset() will return correctly.
  5. LPH

    LPH Well-Known Member

    Thank you.

    If I understand you correctly, you are stating that line is shorthand. Therefore, I searched and found one reference to this shorthand and the post stated it failed. Do you have another reference suggesting that this works as expected?

    Update: As soon as I added the = NULL for that variable as well as another one then the WordPress debug bar errors for undefined variables disappeared.
    Last edited: Jun 12, 2013
  6. Jeremy P

    Jeremy P Well-Known Member

    Wouldn't !isset() return correctly whether that line was there or not..?
    James likes this.
  7. LPH

    LPH Well-Known Member

    The author of the script answered me late last night. He stated that line does nothing. It is his shorthand as a means of a comment ....
    Jeremy P likes this.

Share This Page