Title: simple php echo question
Last modified: August 18, 2016

---

# simple php echo question

 *  [syrupcore](https://wordpress.org/support/users/syrupcore/)
 * (@syrupcore)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/simple-php-echo-question/)
 * This should work but it’s not. I’m sure I have my syntax screwy.
 * `<?php if (count($kids) > 0) {echo "<h2><?php (get_the_title($parent))?></h2>";}?
   >`
 * I have declared this previously:
    ` $kids = get_pages("child_of=$id");`
 * the $kids bit is working fine with a bit used later. I think I just have more
   php all mixed up in the first line. can some one please tell me where?
 * thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [skippy](https://wordpress.org/support/users/skippy/)
 * (@skippy)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/simple-php-echo-question/#post-251062)
 * `<?php
    if (count($kids) > 0) { echo "<h2><?php (get_the_title($parent))?></h2
   >"; } ?>
 * You never close the PHP tag you opened at the very beginning, so opening a new
   PHP tag with `<?php` causes the PHP parser to get confused. Try this:
 * `<?php
    if (count($kids) > 0) { echo '<h2>' . get_the_title($parent) . '</h2>';}?
   >
 * Or:
    `<?php if (count($kids) > 0) { $t = get_the_title($parent); echo "<h2>$t
   </h2>"; } ?>
 * Or even:
    `<?php if (count($kids) > 0) { echo '<h2>'; the_title($parent); echo'
   </h2>'; } ?>
 * I showed you all three of these to highlight certain differences. Note that for(
   I think) every `get_the_*` function there is also a `the_*` function. `get_the_*`
   returns to you the value you requested for use in a variable, or other function(
   like echo). `the_*` displays the value directly to the browser.
 * Note also the different uses of single and double quotes. Single quotes do no
   variable interpolation. So `echo '$foo';` will echo the literal value $foo, dollar
   sign and all. Because they do no interpolation, they’re a little faster.
 * Double quotes do interpolate variables, so `echo "$foo";` will echo the value
   contained in the variable $foo.
 * Hope that helps!
 *  Thread Starter [syrupcore](https://wordpress.org/support/users/syrupcore/)
 * (@syrupcore)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/simple-php-echo-question/#post-251277)
 * Skippy! Thanks so much. I haven’t had a chance to test it but will this afternoon
   and report back. at the moment, I just moved the site to a new server and I managed
   to break it. sweet.
 * you’ve come to my rescue more than once. If you’re in portland, beer is on me.
 * will

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘simple php echo question’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [syrupcore](https://wordpress.org/support/users/syrupcore/)
 * Last activity: [20 years, 8 months ago](https://wordpress.org/support/topic/simple-php-echo-question/#post-251277)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
