如何将另一个网页的输出拉到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/

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

其他解决方案,

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

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

你可以在这里看到regex的作用

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