先に, 出処は http://jacking.x-y.net/entry/htmlspecialchars-htmlspecialcharsdecode-使用 載せる.

cut_lenなんかの 名前で 作られた, 文字列を 切って 与える 関数を たくさん 扱って 見た ことだ. エンコードも 面倒な 仕事だが, & l t ; 私 & g t ; ような 字が 中間に 切られる 蟹 表示 嫌いに 切られる 場合が ある. 蟹に あんな 子供達は 4字で 処理が なったら あんな 子供達が 入って ある 場合は 意図した より もっと 短く 切られる.

それを 解決しようとすれば 下のように コードを 作成すれば なる 敷地.

$text='<朝鮮日報>増えた スレギブニだ.';
$text=htmlspecialchars_decode($text);
$text=cut_len($text);
$text=htmlspecialchars($text);
return $text;

何 こういう シックウロに 言葉だ. ところが たいてい 枝 問題が ある. htmlspecialchars_decode増えた PHP5から ある 関数だ. PHP4で 不可避に 回すと する ホームページは 上 関数を 使う 数 なくて 分かって 作って 使うと する.

私も そうであろうか 思ったが, PHP 関数を js路 具現して おいた のも 見つけた 庭先に PHP5義 関数を 誰か 具現して おいた 蟹 分明 ある ことで 考え, 検索を 日 見たが 捜した のだ.

コードは 下と ようだ.

//for php4
function htmlspecialchars_decode($string, $quote_style = null)
    {
        // Sanity check
        if (!is_scalar($string)) {
            user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' .
                gettype($string) . ' given', E_USER_WARNING);
            return;
        }

        if (!is_int($quote_style) && $quote_style !== null) {
            user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' .
                gettype($quote_style) . ' given', E_USER_WARNING);
            return;
        }

        // Init
        $from   = array('&', '<', '>');
        $to     = array('&', '<', '>');

        // The function does not behave as documented
        // This matches the actual behaviour of the function
        if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) {
            $from[] = '"';
            $to[]   = '"';

            $from[] = ''';
            $to[]   = "'";
        }

        return str_replace($from, $to, $string);
    }

それでは, コンパニオン なったことを.

[ドッ] これ 文を 作成して 私だから PHP4でも 作動する 関数を 見つける 数 あった;; 下の リンクを 参考しなさい.

http://www.php.net/manual/en/function.html-entity-decode.php

[ドッ2] 上 html-entity-decode 関数を 使うから 割れる 字が 発生した. そのため htmlspecialchars_decode 関数を 使うことに した.

- コメント機能はありません。コメントの代わりに[email protected]にメールを送ってください。