【问题标题】:PHP (with codeigniter) Assigning string to a var results in null when the string is longerPHP(使用codeigniter)将字符串分配给var当字符串较长时导致null
【发布时间】:2011-11-27 10:03:30
【问题描述】:

大家好,我好绝望:

我只是给一个变量赋值一个字符串:

$tradersCatalog = 
                    '<div style="float:left; width:700px;  margin:8px 10px 5px 3px;">
    <div class="boxcontent" style="height:130px;"> 
        <div style="clear:both;">
            <div style="float:left; padding:5px;"><img src="" alt="" style="width:241px; height:120px;"></div>
            <div style="float:left; padding:5px; width:430px;">
                <div style="color:orange;"><font color="#555555" size="2"></font></div><div style="float:right"><a href="firms_view.php?&amp;fid=1011#fkatalog"><img src="images/products_detail_button.png" border="0"></a></div><a href="firms_view.php?&amp;fid=1011#fkatalog">
                    <div style="color:#222222;"><font color="red" size="5"></font></div>
                    <div style="font-size:11px; color:#000000;padding-top:5px;">
                        <hr>

                        <hr>
                    </div>
                </a><div style="clear:both;"><a href="firms_view.php?&amp;fid=1011#fkatalog">

                    </a><div style="float:left; margin:0px 0px 20px 0px;"><a href="firms_view.php?&amp;fid=1011#fkatalog">
                        </a>&nbsp;&nbsp;<font color="green"><b></b></font></a>
                    </div>

                    <div style="float:right; margin:0px 0px 20px 0px;">
                    </div>
                </div>
            </div>
            <br><br>
        </div>
        <div style="clear:both;"></div>
    </div>
    <div style="clear:both;"></div>
</div>';

这导致 $tradersCatalog 的值为 NULL。

当我尝试使用较短的字符串时,没关系。什么鬼???

【问题讨论】:

  • 对我来说很好 -> codepad.org/N9oSP279
  • @Alexander Beninski 此代码不足以解决该问题。正如已经发布的那样,代码有效,所以应该有其他你没有说的东西,比如前。您在何处以及如何使用该变量。请发布您在其中创建、使用和显示该 var 的相关代码,然后我们可以交谈。现在只是对不可复制问题的疯狂猜测!

标签: php string codeigniter null


【解决方案1】:

为了简单起见,为什么不将所有的 html 添加到视图中并传入参数(我猜是 href 链接)。这可能有助于发现问题。

$this->load->view('traders_catalog', array('href' => 'fid=1011#fkatalog'));

您可以从控制器调用视图,也可以从另一个视图调用视图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 2021-04-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    相关资源
    最近更新 更多