【问题标题】:how can show 100 character and hide more for expander?如何显示 100 个字符并为扩展器隐藏更多?
【发布时间】:2012-06-26 03:22:19
【问题描述】:

我有一个带有 MySQL 数据库的动态站点,我想像在 Facebook 上一样创建“查看更多”按钮,我可能应该使用 jQuery 扩展器,但我有一个大问题。不知道怎么隐藏更多的字符...

下面是我的代码:

if ( $message = mb_strlen(htmlspecialchars($this->post_message) ) > 200 ); {
    $message = str_cut(htmlspecialchars($this->post_message),100);
    echo $message.'<span style="float:left;clear:both"> <a href="" target="_blank" title="more" style="font-size:9px;" >more</a></span>';
}

谁能为此处理完整的代码? 此代码只是剪切更多字符,但我想隐藏它们并在扩展器中显示!

对不起,我的语言不好,我的英语说得不好:)

【问题讨论】:

    标签: php javascript jquery expander ellipsis


    【解决方案1】:

    你的语法有错误。

    if ( $message   =  mb_strlen(htmlspecialchars($this->post_message) ) > 200 ); {
    

    应该是

    if ( $message   =  mb_strlen(htmlspecialchars($this->post_message) ) > 200 ) {
    

    你的 if 语句后面不应该有;

    str_cut 不是 PHP 函数。你要找的是substr

    在你的情况下,你会这样使用它:

    $message = substr(htmlspecialchars($this->post_message),0,100);
    

    【讨论】:

    • 我知道那个亲爱的。但我的问题在这里 str_cut !我不知道用 str_cut 代替什么代码来工作!
    • 不适用于 $message = substr(htmlspecialchars($this->post_message),0,100);
    猜你喜欢
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 2021-03-03
    • 1970-01-01
    • 2021-11-27
    相关资源
    最近更新 更多