-2

我需要帮助才能让这个 if else 语句正常工作。我在网站上显示了 HTML,但我也需要 php 工作。我不知道在另一个回声中做一个回声的方法(这是不受欢迎的)。任何建议都会有所帮助!

code
<?php
if ( is_user_logged_in() ) {echo "
<div id='fixedbar'>
<div id='boxfloat'>
<div id='header'>
<img src='http://s3.amazonaws.com/punchtab-static/nd/images/favicon.ico' id='favicon'       border='0' onerror='imageNotFound(this, '//s3.amazonaws.com/punchtab-  static/nd/images/bar/shield.png')' onload='imageFound(this)' style='visibility: visible;'>
</div>
<p>
Rewards
<div id='points'>
<div id='user'>
echo 'cosmo_avatar( get_the_author_meta('ID') , 30 )'; ?>
</div>
echo cp_displayPoints($user->ID)'; pts
</div>
<div id='more'>
<a href='/leaderboard'>
<img border='0' src='http://expertcamo.com/wp-content/uploads/2012/12/icon-leaderboard.png' id='leaderboard' alt='Leaderboard' title='Expert Camo Points Leaderboard'</a>

<a href='/catalog'>
<img border='0' src='http://expertcamo.com/wp-content/uploads/2012/12/icon-trophy.png' id='catalog' alt='Catalog' title='Rewards Catalog'</a>

</div>
</p>
<div id='copyright'><a href='/'>
Expert Camo &copy; echo 'date('Y')';</a>
</div>
</div>
</div>
";} else { echo "
<div id='fixedbar'>
<div id='boxfloat'>

</div>
</div>
";}
?>
4

2 回答 2

1

未经测试,但基于您应该工作的内容:

    <?php
if(is_user_logged_in()){
               echo "
                <div id='fixedbar'>
                <div id='boxfloat'>
                <div id='header'>
                <img src='http://s3.amazonaws.com/punchtab-static/nd/images/favicon.ico' id='favicon'           border='0' onerror='imageNotFound(this, '//s3.amazonaws.com/punchtab-      static/nd/images/bar/shield.png')' onload='imageFound(this)' style='visibility: visible;'>
                </div>
                <p>
                Rewards
                <div id='points'>
                <div id='user'>";
                echo cosmo_avatar( get_the_author_meta('ID') , 30 );
                echo "</div>";

                echo cp_displayPoints($user->ID) . 'pts';


                echo "</div>
                <div id='more'>
                <a href='/leaderboard'>
                <img border='0' src='http://expertcamo.com/wp-content/uploads/2012/12/icon-leaderboard.png' id='leaderboard' alt='Leaderboard' title='Expert Camo Points Leaderboard'</a>

                <a href='/catalog'>
                <img border='0' src='http://expertcamo.com/wp-content/uploads/2012/12/icon-trophy.png' id='catalog' alt='Catalog' title='Rewards Catalog'</a>

                </div>
                </p>
                <div id='copyright'><a href='/'>Expert Camo &copy; ";

                echo date('Y');

                echo "</a>
                        </div>
                        </div>
                        </div>";

        }
            else{

                    echo "<div id='fixedbar'>
                            <div id='boxfloat'>
                            </div>
                            </div>";

            }

?>
于 2012-12-22T18:28:47.197 回答
-1

我宁愿你加载一个模板而不是回显所有的html,但是,你可以通过退出引号来调用你的回声中的函数,像这样

<?php echo 'Some text ... ' . cosmo_avatar(get_the_author_meta('ID'), 30) . ' and some more text'; ?>
于 2012-12-22T18:21:51.460 回答