【问题标题】:How can I get the path of the fetch function in the php file?如何在 php 文件中获取 fetch 函数的路径?
【发布时间】:2021-04-10 13:43:41
【问题描述】:

我有一个 JavaScript 函数来从后端获取数据

async getAllExpensesByUser() {
    let response = await fetch("router.php/getAll");
    return response.json();
}

在 router.php 中如何获取路径“/getAll”,以便我可以相应地检索数据?

【问题讨论】:

  • 您应该使用router.php?getAll=1 路径并在php 中使用$_GET["getAll"] 获取它

标签: javascript php


【解决方案1】:

你可以用它来获取uri

basename($_SERVER['REQUEST_URI']);

欲了解更多信息,请访问this linkphp documantion

【讨论】:

  • 这很有帮助。谢谢。
猜你喜欢
  • 2011-08-23
  • 1970-01-01
  • 1970-01-01
  • 2015-03-19
  • 2020-11-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-25
  • 2013-12-20
相关资源
最近更新 更多