-1

I'm working on a wordpress widget that utilizes Johnathan Christopher's 'Widget Image Field' pluggin. I'm confused by this line of code.

$image_id = esc_attr( isset( $instance[$this->image_field] ) ? $instance[$this->image_field] : 0 );

What does the '?' and ':' do?

1 Answers1

0

It is the same that:

if(isset( $instance[$this->image_field]))
{
    $image_id =  $instance[$this->image_field];
}
else
{
     $image_id = 0;
}

This is the ternary operator. Here you can learn about.

Rafael Azevedo
  • 330
  • 2
  • 8
  • You should not ask such a question, and go to practice before asking such question on SO (which is not here for that) – MatRt Jun 07 '13 at 03:42