WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP Syntax? (2 posts)

  1. Tsalagi
    Member
    Posted 4 years ago #

    Just a quicky that I can't find any reference to. I'm working on a template and the php code has this syntax in it and I don't know what it means. What does -> and => do in the following code?

    $getpag[$apage->ID] = $apage->post_title;
    and
    "options" => $styles),
    Thanks in advance

  2. s_ha_dum
    Member
    Posted 4 years ago #

    The -> is object syntax, so $apage->ID is pulling the ID element from the $apage object. If you look at, say, the wpdb object you'll see the same kind of thing.

    The => is an assignment operator for arrays. You could do something like this:

    $a = array();
    $a['options'] = $styles;
    $a['opt2'] = $hithere;

    But you could also do the same thing like this:

    $a = array('options' => $styles, 'opt2' => $hithere);

Topic Closed

This topic has been closed to new replies.

About this Topic