passing variable between pages

后端 未结 6 1396
青春惊慌失措
青春惊慌失措 2020-12-22 02:29

Is it good way to pass variable between pages using $_GET method with url:

and take

6条回答
  •  囚心锁ツ
    2020-12-22 02:55

    It depends on the what the data is for, its type and its length. Usually, passing variables in the query string is fine.

    Be aware that when accepting mutable parameters, you need to verify they are what you expect them to be. For example, I could change ?id=5 to ?id=hello and possibly break your application. To remedy this, we could typecast the ID to an integer:
    $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;

提交回复
热议问题