Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/7.4/lib/php') in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 2
URLデコード

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 27

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/7.4/lib/php') in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 27
 
トップページ >  PHP >  URLデコード
初版2008/11/21: 最終更新日2008/11/21
URLデコード
目次
URLデコード
サンプルコード
サンプル
URLデコード
GETメソッドでフォームデータを送信すると、テキストボックスなどに入力された全角文字や半角英数字、
あるいはクリックされたボタンの全角文字のvalue属性値などに、すべて「%」で始まる半角英数字形式に変換されます。
この変換を「URLエンコード」といい、自動的に行われます。

このURLエンコードされた文字列を通常の全角文字の状態に戻すには、urldecode関数を使います。
引数にURLエンコードされた文字列を指定すると、元に戻された文字列が返されます。


以下がサンプルになります。

サンプルコード
(php部)
<?php
print "受け取ったクエリ文字列をそのまま表示。↓";
// 「送信」ボタンが押された時
if (isset($_GET[btnExec])) {
	print "$_SERVER[QUERY_STRING]";
}

print "クエリ文字列を元に戻して表示。↓";
// 「送信」ボタンが押された時
if (isset($_GET[btnExec])) {
	$decode = urldecode($_SERVER[QUERY_STRING]);
	print "$decode";
}
?>
(html部)
<form method="post">
	<input type="text" name="memo" size="50">
	<input type="submit" name="btnExec" value="送信">
</form>

サンプル

文字列を入力し、「送信」ボタンを押します。


受け取ったクエリ文字列をそのまま表示。↓

Warning: Use of undefined constant btnExec - assumed 'btnExec' (this will throw an Error in a future version of PHP) in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 112
クエリ文字列を元に戻して表示。↓

Warning: Use of undefined constant btnExec - assumed 'btnExec' (this will throw an Error in a future version of PHP) in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 118

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 134

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/7.4/lib/php') in /home/users/2/moriya-h5/web/confrage/php/confirmation/urldecode/urldecode.php on line 134