如何将另一个网页的输出拉入 PHP 脚本

How to pull the output of another webpage into a PHP script

就像 PHP include 我如何将一个页面的输出(不是标记)拉到另一个页面的 php 脚本中。

https://api.wordpress.org/secret-key/1.1/salt/

这 link 输出 PHP 定义的常量。我想将此输出包含在另一个 PHP 页面中,以便在该 PHP 脚本中使用这些常量。

您可以使用 PHP simpleHtmlDom 比你可以解析你的 link https://api.wordpress.org/secret-key/1.1/salt/ 并使用正则表达式来获取常量

其他解决方案,

$homepage = file_get_contents('https://api.wordpress.org/secret-key/1.1/salt/');
ereg("'(.*)', {1,}'(.*)'", $homepage, $regs);

循环数组 $regs 以获得常量。

您可以看到正在运行的正则表达式 here