1:我觉得不加字段实现地可能性不大
2:
因为$_SESSION["xxx"]是全局变量,所以不能用这个方法来实现,例如:
function destroy_foo() {
    global $foo;
    unset($foo);
}
$foo = 'bar';
destroy_foo();
echo $foo;
上面地echo语句返回地是:
bar
 
浅妄薄见,望与斟酌

解决方案 »

  1.   

    多谢回答!
    1. 如果加字段的话,字段里又存储什么值最简便呢?2.下面是我从php.net的在线文档中摘录的:
    Example 3. Unregistering a variable with $_SESSION. 
    <?php
    session_start();
    // Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
    unset($_SESSION['count']);
    ?>3.追问一个问题,用户提交的文章存储于数据库中,查询时以表格显示,怎么避免表格被“撑爆”(就是超出设置的表宽,很难看)?
      

  2.   

    1.用文章类别或者文章关键字
    2.应该可以unset成功的。
    3.用css控制:
    在head标记之间加上:
    <style>
    td{word-break:break-all;}
    </style>
      

  3.   

    1:不知道你的“相关文章”的定义是什么,如果是象水木清华那样的是有关回复的话,这个字段当然是楼主帖子的标题。
      如果想要比较智能一点的话,比如说下面两条新闻
      a:江主席访美
      b:访美实录
    我想实现起来比较麻烦一些,这应该是认为分类的,而不是通过数据库查询能实现的吧2:to czlearner() :
    你说的我也看到了,这应该是php的一个bug.
    我的做法是:1:如果你的register_blobals开的话,先用session_unregister()然后再用unset();  2:如果没有开,unset($GLOBALS['_SESSION']['foo']);
    3:楼上说的是一种方法,我的方法是,只要在你的.php文件的代码中限定表格的宽度就可以了,文章内容就会自动的换行
      

  4.   

    多谢两位的大侠,我的思路是:
    1.如果不添字段的话,截取现在文章的标题的2/3做为查询条件,符合的就认为相关;2.为了向以后的PHP兼容^\_/^,坚持使用$_SESSION['foo'],如果register_globals开的话,先用$_SESSION['foo']=""然后再用unset;如果没有开,直接unset,已测试通过;3.css我不熟,能解释一下td{word-break:break-all;}的含义吗?
      

  5.   

    可是刚试了,不行啊!我的情况是为了在文章中显示特殊的效果,支持了html,结果有些直接从网上贴下来的文章,就撑爆了我用来显示的文章内容的表格!
      

  6.   

    try:
    <table width=100 border> 
    <tr>
    <td style="word-break:break-all">asadsfasdasfdasfdfasdfadsfadsfadsfasdfadsfadsfasfddfasdfasfdaffdassssssssssssssssssssssssssssssss</td>
    </tr>
    </table>绝对可以
      

  7.   

    真的不行啊,刚才我说了,提交的文章中夹杂了不少html的符号,不是纯文本(因为这是从网页上直接贴下来的),而我的系统又支持html显示。
      

  8.   

    你用htmlspecialchars转换以后在输出就行了
      

  9.   

    wordwrap --  Wraps a string to a given number of characters using a string break character. 
    Description
    string wordwrap ( string str [, int width [, string break [, int cut]]])
    Returns a string with str wrapped at the column number specified by the (optional) width parameter. The line is broken using the (optional) break parameter. wordwrap() will automatically wrap at column 75 and break using '\n' (newline) if width or break are not given. If the cut is set to 1, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example). Note: The optional cut parameter was added in PHP 4.0.3 
    Example 1. wordwrap() example$text = "The quick brown fox jumped over the lazy dog.";
    $newtext = wordwrap( $text, 20 );echo "$newtext\n";
     
     
    This example would display: The quick brown fox
    jumped over the lazy dog.
     
      

  10.   

    If you're having problems with a small fixed width table/table cell being stretched by people typing entering long text (such as a URL or an email address), then one (MSIE only, unfortunately) solution is to use style="table-layout:fixed" in the <table> tag. This will break any words that would normally expand your table and mess up your layout. wordwrap() can't help in this situation because you want to wrap if the text is wider than X pixels, rather than X characters, which of course PHP has know way of knowing.经测试,上面的方法管住了表格,但内容却有很多不能正常显示了。
      

  11.   

    <td style="word-break:break-all"><?=htmlspecialchars($outString)?></td>
      

  12.   

    我说系统支持使用html,就是经过了htmlspecialchars的处理呀
      

  13.   

    to vivanboy(我是谁?) :
    我用英文也很好啊----直接加限定