<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> $length = $length - 30;<li> $first = substr ($url, 0, -$length);<li> $last = substr($url, -15);<li> $new = $first."[ ... ]".$last;<li> return $new;<li> }else {<li> return $url;<li> }<li>}<li>?></li> <li> </li> <li>// 使用方法</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>