php - 如何使用javascript从php文件中获取file_get_contents的路径

标签 php javascript file-get-contents

有没有办法使用 javascript 获取/检索 php 文件中“file_get_contents”中的值/参数?我的 PHP 代码是……

<?php
  (file_get_contents("http://localhost/" . $_GET["path"] . "?json=" . urlencode($_GET["json"])));
?>

我想使用 javascript 在我的 html 中显示“file_get_contents”中的值。这里有人可以帮助我吗?请...谢谢..

编辑...如何使用 javascript 在我的 html 中显示 xmlhttprequest?谢谢

最佳答案

PHP 是服务器端,而 Javascript 是客户端。将参数传递给 js 的唯一方法是在 ajax 调用中通过数组返回它们(即作为 json 返回)或将参数回显到 js 将保存它们的最终页面。

关于php - 如何使用javascript从php文件中获取file_get_contents的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5321511/

相关文章:

javascript - 多个 SystemJS/JSPM 包的无摩擦开发

javascript - 事件冒泡和传播层次结构

curl - file_get_contents 和 curl 都不起作用

php - 使用 PHP 和 Websockets 的实时聊天应用程序

php - 搜索多个单词 PHP

javascript - 希望使用从模型传递的数据更改甘特图上的背景颜色

php - file_get_contents 的超时在 PHP 中不起作用

PHP file_get_contents 添加空格?

php - 更改附件名称 : wp_mail PHP

IIS 上的 PHP - 执行返回 1