word文件中的PHP文件显示带有空格的变量

时间:2018-04-10 13:40:56

标签: php html variables

你真的很抱歉问什么可能是一件简单的事情。

下面的html(group=".$object->organizer_name.">) 输出以下内容:

<div id="buy-ticket" group="Test" with="" space=""

什么时候应该=

<div id="buy-ticket" group="Test with space"

我看过这个艺术: how to display the entire variable with space in textbox in php

尝试使用.$object[organizer_name.]而不是运气: - (

我猜测它与"'

的展示位置有关

感谢您的帮助!!

下面的完整代码:

if(!empty($ORGMeta['evcal_org_exlink'])) {
    $orgNAME = "<span class='evo_card_organizer_name_t'>
                    <a ".( $newdinwow )." href='" . evo_format_link($ORGMeta['evcal_org_exlink']) . "'>".$object->organizer_name."</a>
                </span>";
} else {
    $orgNAME = "<div id='buy-ticket' group=".$object->organizer_name.">   
                    <div id='selectTicketValidation' class='validation'></div>
                    <div id='selectTicketGroup' class='selector'>
                        <p>The ticket selector is loading.</p>
                        <p>Please check you have JavaScript enabled.</p>
                        <p><a href='javascript:TygitTickets.start();'>click here to manually start the ticket selector</a></p>
                    </div>
                    <div id='selectTicketSubGroup' class='selector'></div>
                    <div id='selectTicketDate' class='selector'></div>
                    <div id='selectTicketTime' class='selector'></div>
                    <div id='selectTicketTypes' class='selector'></div>
                </div>";
}   

2 个答案:

答案 0 :(得分:0)

如果这是在使用字符串的双引号的回声中(我想它是),你需要为group属性添加单引号,如下所示:

<div id='buy-ticket' group='".$object->organizer_name."'>   

完整的东西就像echo "<div id='buy-ticket' group='".$object->organizer_name."'>";

编辑后的补充:

是的,这是我的想法。所以这一行

$orgNAME = "<div id='buy-ticket' group=".$object->organizer_name.">   

应该是

$orgNAME = "<div id='buy-ticket' group='".$object->organizer_name."'>
[ etc. ]   

答案 1 :(得分:0)

$orgNAME = "<div id='buy-ticket' group='$object->organizer_name'> ";

这样可以正常使用",或者也可以这样做:

  $orgNAME = "<div id='buy-ticket' group='".$object->organizer_name."'> ";