2011-04-13 81 views
0

對不起,我並不真正瞭解PHP的任何內容,即時嘗試做的是在我的WordPress網站上有一個選項頁面,您可以在文本區域輸入代碼,然後它會顯示在我的頁面和所有內容中正在工作(可能不正確,但工作),除非我試圖讓<style type=\"text/css\"></style>顯示在textarea裏面,而不必手動將它們放在那裏。這就是我現在的樣子,但是當我保存時樣式標籤保持重複。例如。 <style type=\"text/css\"></style>保存,然後在文本區顯示<style type=\"text/css\"></style><style type=\"text/css\"></style>如何讓保存在PHP中的textarea不會複製文本?

array( 'name' => 'Header CSS ', 
     'desc' => 'Add your own css between the <style> tags.', 
     'id' => 'nrg_header_css', 
     'type' => 'textarea'), 

<textarea name="nrg_header_css" rows=8 style="width: 98%;"><?php echo stripslashes(nrg_get_option_setting('nrg_header_css')); ?><style type=\"text/css\"></style></textarea> 
     <br /> 
     <p class="submit"> 
     <input name="<?php echo($actname); ?>" type="submit" value="<?php echo($flabel); ?>" />  
     <input type="hidden" name="action" value="<?php echo($actname); ?>" /> 
     </p> 

感謝

+0

您正在尋找在錯誤的結束。你不應該放置一個佔位符到textarea並保存它。只需在真正需要時輸出腳本標記。 – halfdan 2011-04-13 19:33:59

回答

0

嘗試改變:

<textarea name="nrg_header_css" rows=8 style="width: 98%;"> 
<?php echo stripslashes(nrg_get_option_setting('nrg_header_css')); ?> 
<style type=\"text/css\"></style> 
</textarea> 

<textarea name="nrg_header_css" rows=8 style="width: 98%;"> 
<?php 
$content = stripslashes(nrg_get_option_setting('nrg_header_css')); 
if($content=='') 
{ 
    echo '<style type=\"text/css\"></style>'; 
} 
else 
{ 
    echo $content; 
} 
?> 
</textarea> 
相關問題