だから私は次のような文字列を持っています:
$string = "This is a test string. It has characters like these: '";
これらを対応する文字に変換するphp関数はありますか?私の例では、望ましい出力は次のようになります:
print $string
// OUTPUT: This is a test string. It has characters like these: '
だから私は次のような文字列を持っています:
$string = "This is a test string. It has characters like these: '";
これらを対応する文字に変換するphp関数はありますか?私の例では、望ましい出力は次のようになります:
print $string
// OUTPUT: This is a test string. It has characters like these: '
はいあります:
htmlspecialchars_decode($string, ENT_QUOTES);
'
私が知る限り、特定の文字についてはわかりませんhtmlspecialchars
(ENT_QUOTES
フラグ付き)アポストロフィ( ')を'
(先行ゼロ付き)に変換します
'
チェックする価値 のある正確な動作
編集:私はテストを行いましたが、うまくいきます:)
html_entity_decode()を使用できます
逆htmlentitiesのようなものです。入力文字列で引用符を使用する場合は、2 番目のパラメーターをに設定する必要がありますhtml_entity_decode()
。ENT_QUOTES
実際に見てみましょう: http://sandbox.onlinephpfunctions.com/code/7f4649eb47a8e639c514787a100b63bbad4bc8c6