Memo

メモ > 技術 > プログラミング言語: PHP > URLエンコード

URLエンコード
標準関数で対応できるが urlencode と rawurlencode が存在する。 それぞれ urlencode … 半角スペースを「+」に変換し、半角チルダを「%7E」に変換する。 rawurlencode … 半角スペースを「%20」に変換し、半角チルダは「~」のまま変換しない。 という処理内容になっている。 rawurlencode 関数の方がRFC3986に沿った変換を行うため、 URLエンコードは urlencode 関数ではなく rawurlencode 関数を使う方が無難。 PHP: urlencode - Manual https://www.php.net/manual/ja/function.urlencode.php PHP: rawurlencode - Manual https://www.php.net/manual/ja/function.rawurlencode.php 【PHP入門】URLエンコードする方法(urlencode) | 侍エンジニア塾ブログ(Samurai Blog) - プログラミング入門者向けサイト https://www.sejuku.net/blog/25909

Advertisement