<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_65991"> <div class="blockcode"> <div id="code_y6K"><ol> <li><?php<li>function shorturl($url){<li> $length = strlen($url);<li> if($length > 45){</li> <li> $length = $length - 30;</li> <li> $first = substr($url, 0, -$length);</li> <li> $last = substr($url, -15);</li> <li> $new = $first."[ ... ]".$last;</li> <li> return $new;</li> <li> }else{</li> <li> return $url;</li> <li> }</li> <li>}</li> <li>?></li> <li> </li> <li>// USAGE</li> <li> </li> <li><?php<li> <li>$longurl= "http://www.google.com/search?q=symfony project&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:tr:official&client=firefox-a";<li>$shorturl = shorturl($longurl);<li>echo "<a href="$longurl">$shorturl</a>";</li> <li> </li> <li>?></li> </ol></div> <em onclick="copycode($('code_y6K'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> PHP</div> <div id="comment_65991" class="cm"> </div> <div id="post_rate_div_65991"></div> <br><br>