2017-02-28 71 views
0

我的網站主題中包含以下一段PHP代碼。我卡住的地方是,如果$ sec_title的值包含撇號,那麼文本不會顯示。但沒有撇號,它包含罰款。我如何修改這個以防止這個問題?如果變量文本包含撇號,PHP值不會顯示

<?php 
if ($sec_title) { 
echo do_shortcode("[onex_section_header 
title={$sec_title} 
subtitle='{$sec_subtitle}']" 
); 
} ?> 
+0

嘗試添加₩之前「 –

+0

能否請你展示什麼呢你的do_shortcode函數? –

+0

http://stackoverflow.com/questions/6269188/how-to-escape-only-single-quotes可能會幫助你。嘗試使用json_encode() –

回答

0

嘗試使用:

$sec_title = addslashes($sec_title) 

您迴應之前,或嘗試切換雙和單引號爲使

echo do_shortcode('[onex_section_header 
title={$sec_title} 
subtitle="{$sec_subtitle}"]' 
); 
相關問題