フォーラム@nifty | フォーラム・サークル | サイトマップ | ヘルプ |
掲示板 コラム お役立ち イベント リンク   | FHPGサイトマップ | お問い合わせ |
TOP > お役立ち > ASP de PHP > htmlspecialchars  

htmlspecialchars 関数

Scripting by かっしい (2004/02/11 登録)

 ASP with VBScript で PHP の便利な関数を定義してみる (1)

htmlspecialchars()

 特殊文字をHTMLエンティティに変換する関数。

関数の説明

 htmlspecialchars (strText as String, intQuatestyle as integer) as string

 → PHPにおけるこの関数の説明を見る。

htmlspecialchars のソース

<%
public Const ENT_NOQUOTES = 4
public Const ENT_QUOTES = 2
public Const ENT_COMPAT = 1

public function htmlspecialchars(strText,intQuatestyle)

  strText = Replace(strText,"&","&amp;")
  strText = Replace(strText,"<","&lt;")
  strText = Replace(strText,">","&gt;")

  Select Case intQuatestyle
    Case ENT_COMPAT
      strText = Replace(strText,"""","&quot;")
    Case ENT_QUATES
      strText = Replace(strText,"""","&quot;")
      strText = Replace(strText,"'","&#039;")
    Case ENT_NOQUATES
  End Select

  htmlspecialchars = strTemp

End Function

%>

※ ただし、PHP4.1.0以降から定義されている文字セット指定引数は指定できない。

ページのトップへ
個人情報保護ポリシー
Copyright© NIFTY 2006 All Rights Reserved.
Copyright© FHPG 2006 All Rights Reserved.