Forums

PHP syntax question (3 posts)

  1. RightWorks
    Member
    Posted 4 weeks ago #

    In this statement:

    $wp_query->post_count

    what is the arrow doing?

  2. ClaytonJames
    Member
    Posted 4 weeks ago #

    I'm going to take a W.A.G. at this one, so don't laugh at me. Okay, you can laugh if you want to. I will state it in the form of a question for anyone who knows the correct answer... ('cause I don't really know either). :P

    Doesn't "->" simply indicate that "post_count" is to be the object property or variable shown by $wp_query? Am I even close, or is there more to it than that?

  3. mtw28
    Member
    Posted 4 weeks ago #

    Hi, that's pretty much it, the arrow there is referencing a method or property of a defined php class, in this case the $wp_query object. In this usage it's a bit like getting the value of an array. Read more about $wp_query properties here.

    More reading classes in the php manual here.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.