有人可以解释这个PHP代码吗? [关闭]

    <h1 class="site-title">
       <a href="<?php echo esc_url( home_url( '/' ) ); ?>" 
       rel="home"><?php bloginfo( 'name' ); ?>
       </a>
    </h1>
    if (is_category('Ponies')) { ?>
      // overlay a pretty rainbow on the logo for the ponies category
       <img id="rainbow"
          src='<?php bloiginfo('template_directory');?>/img/rainbow.png" 
          alt="OMG! Ponies! " />
    <?php  } ?>

I'm having trouble matching the PHP tags. The comment for the code says "Now any time the category of the content is Ponies, your header also includes the rainbow.png." But it's clear how that is happening. The actual code is on p245 of WordPress Design and Developement by Williams. Thanks for putting another pair of eyes on it.

"If" is not inside <?php ... ?>. Must be:

<?php if (is_category('Ponies')) { ?>

I prefer to use <?php if (condition): ?> when there's HTML in-between. But anyhow...

1) The if() statement needs to be inside php tags.

2) You don't need echo to retrieve the bloginfo.

bloginfo() documentation

3) You've misspelled bloginfo at the bottom...

My code:

<h1 class="site-title">
   <a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
      <?php $bloginfo('name'); ?>
   </a>
</h1>

<?php if (is_category('Ponies')) : ?>
    <img id="rainbow"
         src="<?php get_bloginfo('template_directory') . '/img/rainbow.png'; ?>"
         alt="OMG! Ponies!" />
<?php endif; ?>