2011-02-15 97 views
0

你好,我得到了同樣的問題,因爲無法看到新行

php :: new line in textarea?

或繼承人的錯誤。 (不換行)

enter image description here

,但它似乎在上面的鏈接它不是回答得很好。

the var_dump($post['content']);顯示我

或類似

<pre dir="ltr" class="xdebug-var-dump"><small>string</small> <font color="#cc0000">'Duis libero sapien, cursus id tempus a, sollicitudin at urna. Maecenas elementum molestie massa quis pharetra. Donec eu libero ipsum. Aenean laoreet, tellus at pretium porta, nisl massa sodales massa, non laoreet sapien velit a neque. Praesent eleifend urna et diam sollicitudin eget pretium quam viverra. Sed rutrum enim quis lectus volutpat eleifend. 





Nam in augue at diam tempus feugiat ac eu orci. Morbi pellentesque consequat lacinia. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesqu'...</font> <i>(length=634)</i></pre> 

enter image description here

繼承人如何我出來把它。

<textarea name="content" cols="100" rows="50"><?php echo $post['content']; ?></textarea> 

繼承人應該是什麼樣子

enter image description here

感謝拜訪。

亞當·拉馬丹

編輯

我對這個問題非常抱歉。這個問題是肯定的IM壓縮從視圖中的每個輸出,

繼承人的功能

public function compressor($buffer) 
{ 
    $search = array(
     '/(\s)+/s', // shorten multiple whitespace sequences <- THE MAIN PROBLEM 
     '/<!--(.|\s)*?-->/', //strip html comments 
     '/\>[^\S ]+/s', //strip whitespaces after tags, except space 
     '/[^\S ]+\</s', //strip whitespaces before tags, except space 
    ); 
    $replace = array(
     '\\1', 
     '', 
     '>', 
     '<' 
    ); 

    $buffer = preg_replace($search, $replace, $buffer); 
    return $buffer; 
} 

繼承人,我怎麼輸出自己的看法

protected function view($view, $data = NULL) 
{ 
    require_once 'libraries/core.views.php'; 
    $views = new Views; 
    if (config('compress')) { 

     /* See @ref #1 
     we are useing compressor just becouse ob_gzhandler dont support UTF-8 at the 
     header, see http://php.net/manual/en/function.ob-start.php#91963 
     */ 
     ob_start(array($this,'compressor')); 
     # ob_start("ob_gzhandler"); 
    } 

    #renders the data into view vars 
    if (isset($data)) { 
     foreach ($data as $name => $val) { 
      $$name = $val; 
     } 
    } 

    #require 'libraries/language/'. config('language') .'.php'; 
    $path = "application". DS ."views". DS . $view .".php"; 
    require $path; 
    return TRUE; 

    if (config('compress')) { 
     while (ob_get_level() > 0) { 
      ob_end_flush(); 
     } 
    } 
} 

一次抱歉,並感謝!

+0

你的意思,你要自動換行的文本以適合文本區域寬度? – Kel 2011-02-15 14:05:42

+0

它應該顯示換行符,編輯我的帖子。 – 2011-02-15 14:07:09

回答

1

答案很簡單。

有一些代碼會刪除額外的換行符。
你必須調查你的代碼,找出問題線並擺脫它。
沒什麼大不了

快速檢查你可以嘗試打印$_POST['content'],最有可能包含原始值