LoginSignup
0
0

More than 5 years have passed since last update.

[PHP]htmlspecialchars関数でエスケープ

Last updated at Posted at 2018-12-24
<?php
function h($s){
    return htmlspecialchars($s, ENT_QUOTES, 'utf-8');
}

「htmlspecialchars」はHTML用のエスケープ関数とのこと。

上記いついては、ENT_QUOTESで「'」と「"」を、ともに変換している。
utf-8は、もちろん文字コードUTF-8のこと。

つまり、ここでは引数$sに対して、「'」および「"」を変換し、UTF-8に固定しているという形になる。

参照:http://php.net/manual/ja/function.htmlspecialchars.php

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0