0
0

More than 3 years have passed since last update.

【PHP・laravel】クエリパラメータを送る時まとめ(getとrequest)

Posted at

初歩的なことですが、調べてもなかなか出てこなかったため、記録します。

HTMLからPHP側に送る

sample1.laravel.php
<a harf="http://ここがURL?suji=1">送信</a>
sample2.laravel.php
<a harf="http://ここがURL?moji='文字'">送信</a>

php側

index.php
$get1 = $_GET['suji'];//1
$get2 = $_GET['moji'];//'文字'

PHP内のやり取り(関数から関数)

数値や文字を送るとき

index.php
function a(){
  redirect('/b?suji=1');
}

function b(){
  $request1 = $_REQUEST['suji']//1
}
index.php
function a(){
  redirect("/b?moji='文字'");
}

function b(){
  $request2 = $_REQUEST['moji']//文字
}

変数を送るとき

index.php
function a(){
  $count = 2;
  redirect('/b?count='.$count);
}

function b(){
  $request3 = $_REQUEST['count']//2
}
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