将target =“_ blank”插入链接。

时间:2014-04-11 08:45:25

标签: php

我想在此按钮中插入target_blank,但我不知道如何。

我尝试将其插入到href括号中,但它出现了错误,我的PHP知识非常低。

非常感谢有人能帮助我。 (我想将它插入“原始形式”部分而不是“弹出形式”)。

<?php
                    $pricing = $subscription->get_pricingarray();

                    if($pricing) {
                        ?>
                        <span class='link'>
                            <?php

                                if(isset($M_options['formtype']) && $M_options['formtype'] == 'new') {
                                    // pop up form
                                    $link = admin_url( 'admin-ajax.php' );
                                    $link .= '?action=buynow&amp;subscription=' . (int) $sub->id;
                                    $class = 'popover';
                                } else {
                                    // original form
                                    $link = '?action=registeruser&amp;subscription=' . (int) $sub->id;


                                    $class = '';
                                }

                                if(empty($linktext)) {
                                    $linktext = apply_filters('membership_subscription_signup_text', __('Complete Registration', 'membership'));
                                }

                                $html = "<a href='" . $link . "' class='button " . $class . " " . apply_filters('membership_subscription_button_color', 'blue') . "'>" . $linktext . " </a>";
                                echo $html;
                            ?>

1 个答案:

答案 0 :(得分:3)

您需要使用反斜杠转义引号,如下所示:

$html = "<a href='" . $link . "' target=\"_blank\" class='button " . $class . " " . apply_filters('membership_subscription_button_color', 'blue') . "'>" . $linktext . " </a>";