Forum Moderators: coopster

Message Too Old, No Replies

PHP Within PHP

         

almo136

2:31 am on Jun 19, 2009 (gmt 0)

10+ Year Member



Hi,

I have this line of code:

<a href="http://mysite.com/wordpress/?author=<?php echo wp_get_current_user()->ID; ?>">Category</a>

This does what I want it to do. However I would like to insert this inside another piece of PHP. Like this:

<?php if (is_user_logged_in() ) {
echo '
<div class="dbx-box">
<h3 class="dbx-handle">Categories</h3>
<div class="dbx-content">
<ul>
<a href="http://mysite.com/wordpress/?author=<?php echo wp_get_current_user()->ID; ?>">Category</a>
</ul>
</div>
</div>';}
?>

This doesn't work. I'm assuming it's because I have php tags nested within php tags.

Does anyone know how I would fix this?

Thanks!

rob7591

2:42 am on Jun 19, 2009 (gmt 0)

10+ Year Member



<?php if (is_user_logged_in() ) {
echo '
<div class="dbx-box">
<h3 class="dbx-handle">Categories</h3>
<div class="dbx-content">
<ul>
<a href="http://mysite.com/wordpress/?author='. wp_get_current_user()->ID . '">Category</a>
</ul>
</div>
</div>';}
?>

Should work.. You can take out the PHP tags because they're already open.

almo136

2:51 am on Jun 19, 2009 (gmt 0)

10+ Year Member



that worked. Thanks!