【问题标题】:php echo form inside div "wp"div“wp”内的php echo表单
【发布时间】:2014-11-11 14:02:22
【问题描述】:

我的 php 代码有问题,当我尝试在 php 中回显表单时,我在 div 之外看到它。

<?php
if ( is_user_logged_in() ) {
    echo '<div class="loginformheader" style="margin-top: 0;">
                <div id="reg-login"><a href="'. wp_logout_url( get_permalink() ).'">خروج</a></div></div>';
} else {
    echo '<div class="loginformheader">'.header_login_form().'<div id="reg-login"><a href="'.site_url('/wp-login.php?action=register').'">تسجيل</a><span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div>';
}
?>

输出

            <p class="login-username">
                <label for="user_login"></label>
                <input type="text" name="log" id="user_login" class="input" value="" size="20" placeholder="اسم المستخدم">
            </p>
            <p class="login-password">
                <label for="user_pass"></label>
                <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" placeholder="كلمة المرور">
            </p>

            <p class="login-remember"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever"> تذكرني</label></p>
            <p class="login-submit">
                <input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="تسجيل الدخول">
                <input type="hidden" name="redirect_to" value="http://localhost:8080/wordpress/2014/10/30/links-post-2/">
            </p>

        </form><div class="loginformheader"><div id="reg-login"><a href="http://localhost:8080/wordpress/wp-login.php?action=register">تسجيل</a><span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div>                <hgroup class="site-branding">
                    <a href="http://localhost:8080/wordpress/" rel="home"><img class="site-logo" src="http://localhost:8080/wordpress/wp-content/themes/merwaa/img/logo.svg"></a>

也许我的英语不太好,对不起。 你能帮帮我吗?

【问题讨论】:

  • 显示 PHP 生成的源代码
  • 这听起来像是 CSS 问题而不是 php 问题。如果我们能看到该页面,将更容易解决。
  • @Justinas 好的,我编辑了它
  • 这段代码似乎对我有效,我只是不明白。为什么要创建$loginformheader,然后是echo呢?为什么不echo 只是那个字符串?问题会出现在您的代码周围的其他地方。
  • @lolka_bolka 我是 php 的初学者,我只是试图用这种愚蠢的方法解决它

标签: php html wordpress


【解决方案1】:

看看你的header_login_form() 函数。几乎可以肯定echos 是表单,而不是将其作为字符串返回。如果是这种情况,它会在评估时为echoed,这将在可以评估它所在的字符串之前。试试这个:

<?php
if ( is_user_logged_in() ) {
    echo '<div class="loginformheader" style="margin-top: 0;">
                <div id="reg-login"><a href="'. wp_logout_url( get_permalink() ).'">خروج</a></div></div>';
} else {
    echo '<div class="loginformheader">';
    header_login_form();
    echo '<div id="reg-login"><a href="'.site_url('/wp-login.php?action=register').'">تسجيل</a><span>|</span><a style="cursor: pointer;" id="logina">دخول</a><i class="fa fa-angle-up"></i></div></div>';
}
?>

【讨论】:

    猜你喜欢
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-01
    相关资源
    最近更新 更多