How to pass parameters with `include`?

前端 未结 6 1390
醉梦人生
醉梦人生 2021-02-15 16:50

I have a PHP script called customers.php that is passed a parameter via the URL, e.g.:

http://www.mysite,com/customers.php?employeeId=1

Inside my customers.php s

6条回答
  •  误落风尘
    2021-02-15 17:27

    You can't add a query string (Something like ?x=yyy&vv=www) onto an include like that. Fortunately your includes have access to all the variables before them, so if $_GET['employeeId'] is defined before you call:

    include 'customers.php';
    

    Then customers.php will also have access to $_GET['employeeId'];

提交回复
热议问题