PHP GET メソッド

WBOY
リリース: 2024-08-29 13:01:56
オリジナル
900 人が閲覧しました

PHP プログラミング言語の Get メソッドは、指定された/特定のリソースからデータをリクエストする場合に非常に役立ちます。これは、特定のリソースからデータを要求する HTTP リクエスト メソッドの 1 つです。 HTTP は通常、サーバーとクライアント間の要求/応答プロトコルのようなものと同じように機能します。通常、クライアント ブラウザは特定のサーバーに HTTP リクエストを送信しますが、サーバーはクライアントに特定の応答を返します。このリクエスト/レスポンスには、特定のリクエストに関するステータス情報が含まれています。このリクエスト プロセスは、PHP プログラミング言語の GET メソッドから行うことができます。

広告 このカテゴリーの人気コース PHP 開発者 - 専門分野 | 8コースシリーズ | 3 つの模擬テスト

無料ソフトウェア開発コースを始めましょう

Web 開発、プログラミング言語、ソフトウェア テスト、その他

構文:

$_GET["name1"]
ログイン後にコピー

PHP GET メソッドはどのように機能しますか?

通常、PHP プログラミング言語の GET メソッドは、URL スペース/アドレス バー スペース上のほとんどの情報を表示するため、安全でないタイプのメソッドです。 GET メソッドの使用はデータ送信に限定されますが、GET METHOD を使用するとデータを高速に送信できます。これは、クエリ文字列にほかならないいくつかの URL パラメーターを介して現在の特定のスクリプトに渡される連想配列変数の 1 つでもあります。この配列はクエリ文字列を要求します。指定されたソース/リソースからデータをリクエストすることで、GET METHOD を通常の PHP プログラムで動作させることができます。

GET メソッドは、ユーザーが特定のページリクエストに追加してエンコードされた情報を送信することによっても機能します。ページは「?」で区切られたエンコードされた情報になります。 URL アドレスバースペースの文字。 GET メソッドは、特定のブラウザの location: ボックスのサーバー ログに表示される非常に長い文字列を生成します。送信のみ 1024 文字に制限されます。 GET メソッドでパスワードなどの安全な情報を渡すと、サーバーに送信されるため、重要で安全な情報には使用しない方がよいでしょう。 GET メソッドを使用して、ワード ドキュメントや画像などのバイナリ データを独自のサーバーまたは他のサーバーに送信することはできませんでした。データには、GET METHOD コンセプトによって送信される QUERY_STRING 環境変数を使用してアクセスできます。送信されたデータ/情報にアクセスするには、ほとんどの場合 $_GET が使用されます。

PHP で GET メソッドを実装する例

以下は PHP GET メソッドのメソッドです:

例 #1

これは、PHP プログラミング言語の GET メソッドの使用例です。ここでは、最初に error_reporting() 関数を使用してエラーを 1 回処理します。次に、x1 変数と y1 変数が GET METHOD f1 値と s1 値とともに使用されます。次に、x1 変数値と y1 変数値を合計するために z1 変数が作成されます。次に、echo ステートメントは z1 変数の値を表示します。次に、フォームメソッドではGETメソッドが使用されます。フォーム内

タグは、特定の列と行を含むテーブルを作成するために使用されます。f1 値と s1 値は、x1 変数と y1 変数に情報を取得するために渡されます。次に、z1 変数値が作成され、ブラウザ結果の上部に表示されます。出力をチェックして、値を入力する前後で結果がどのようになるかを確認してください。

コード:

<html>
<head>
<title>get_browser1</title>
<?php
error_reporting(1);
$x1=$_GET['f1'];
$y1=$_GET['s1'];
$z1=$x1+$y1;
echo "Sum of the two numbers = ".$z1;
?>
</head>
<body bgcolor="skyblue">
<form method="GET" >
<table border="2" bgcolor="green">
<tr>
<td>Enter the first number for input :: </td>
<td><input type="text" name="f1"/></td>
</tr>
<tr>
<td>Enter the second number for input :: </td>
<td><input type="text" name="s1"/></td>
</tr>
<tr align="center">
<td colspan="3" >
<input type="submit" value="+"/></td>
</tr>
</table>
</form>
</body>
</html>
ログイン後にコピー

出力:

1_1:

PHP GET メソッド

1_2:

PHP GET メソッド

例 #2

以下の GET METHOD コンセプトの例では、ユーザーはテキスト ボックス内に名前を入力する必要があります。名前を入力して「入力した名前を送信する」をクリックすると完了です。入力ボックスの上に入力した名前/単語の出力が表示され、その後、前と同じように通常の入力ボックスが再び表示されます。 PHP プログラミング言語の GET メソッドにより、ユーザーは URL 内の入力を確認することもできます。ここでは最初にGET METHOD呼び出しでechoステートメントが使用されていますが、その中にある文字列名/値には値がありません。そこで、FORM メソッドを使用して値を渡します。次に、入力名の入力をよりよく理解するためにこの表を使用します。入力して送信ボタンをクリックすると、名前が上部に表示されます。

コード:

<html>
<head>
<?php
echo $_GET['n1'];
?>
<title>get_browser2 pavankumar sake</title></head>
<body bgcolor="sky color">
<form method="GET">
<table border="2" bgcolor="green">
<tr>
<td>Enter the name for input :: </td>
<td><input type="text" name="n1"/></td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="show the input name"/></td>
</tr>
</table>
</form>
</body>
</html>
ログイン後にコピー

出力:

PHP GET メソッド

Example #3

This is the example of implementing the GET METHOD to show the name and the age which is entered in the user boxes. Here I entered “pavankumar sake” as name value and “23” as the age value. Here at first, inside of the PHP tags name1 and age1 are used inside, and then using the echo statement they will be printed but those values got from the FORM METHOD below. Check out the output 3_1 and output 3_2 to understand the concept better.

Code:

<?php
if( $_GET['name1'] || $_GET['age1'] ) {
echo "Welcome ". $_GET['name1']. "<br />";
echo "You are ". $_GET['age1']. " years old.";
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name :: <input type = "text" name = "name1" />
Age :: <input type = "text" name = "age1" />
<input type = "submit" />
</form>
</body>
</html>
ログイン後にコピー

Output:

3_1:

PHP GET メソッド

3_2:

PHP GET メソッド

Advantages of PHP GET Method

Since some data which will be sent by the GET METHOD of the PHP language will be displayed in/inside of the specific URL, it will only be possible in order to bookmarking the page which is with the specific query values of the string/strings. The GET METHOD will help the specific method requests can/should be cached and the Get Method requests remains in our browser history. The Get Method requests can/will be bookmarked.

Conclusion

I hope you learnt what is the definition of PHP Get Method along with its syntax and explanation, How the PHP Get Method works along with the various examples and explanation of those examples, Advantages of the Get Method etc. to under the Get Method concept better.

Recommended Article

This is a guide to the PHP GET Method. Here we discuss the introduction, syntax, and working of Get Method in PHP along with examples and advantages. You can also go through our other suggested articles to learn more –

  1. Abstract Class in PHP
  2. Socket Programming in PHP
  3. PHP Frameworks

以上がPHP GET メソッドの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
php
ソース:php
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!