PHP Operator Question. What does the colon (:) operator do?

My question relates to the colon at the end of the following line:

if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) :

This is typically found in Wordpress themes. there is never an opening curly bracket after the if statement, like so:

[code fragment]

<?php /* Widgetized sidebar, if you have the plugin installed. */

if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) :



<?php include (TEMPLATEPATH . '/searchform.php'); ?>


<!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.


<p>A little something about you, the author. Nothing lengthy, just an overview.</p>



<?php if ( is_404() || is_category() || is_day() || is_month() ||

is_year() || is_search() || is_paged() ) {

?> <li>

[/code fragment]


And no, it is not a semi-colon.

5 Answers

  • 1 decade ago
    Best Answer

    Hi Friend,

    This (:) operator mostly used in embedded coding of php and html.

    Using this operator you can avoid use of curly brace. This operator reduce complexity in embedded coding. You can use this(:) operator with if, while, for, foreach and more...

    Without (:) operator



    <?php if(true){ ?>

    <span>This is just test</span>

    <?php } ?>


    With (:) operator



    <?php if(true): ?>

    <span>This is just test</span>

    <?php endif; ?>


    I hope this will help you...

    - nirav soni

  • shanan
    Lv 4
    3 years ago

    Php If Colon

  • shadow
    Lv 5
    1 decade ago

    The colon indicates the start of an if() sequence, until the word endif; is found.

    Look at an example in the website below.

  • 4 years ago

    It means "a is to b as c is to d". For example: 3:5::6:10 As a written analogy, an example might be: cat:kitten::dog:puppy

  • How do you think about the answers? You can sign in to vote the answer.
  • Anonymous
    1 decade ago

    semi-colon(:) isn't an operator.

Still have questions? Get your answers by asking now.