从 PHP 回显本地 ASP.NET url

发布于 2024-10-03 06:13:19 字数 464 浏览 0 评论 0原文

我有一个在 IIS 上运行的 php WordPress 网站。我需要包含来自本地 ASP.NET 页面的响应作为该文件的一部分。不过 PHP 确实不是我最强的语言。

我的代码是:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_SERVER['DOCUMENT_ROOT']+'/GetDesigns.ashx?type=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$localText = curl_exec($ch);
curl_close($ch);
echo $localText;
?>

在浏览器中向 /GetDesigns.ashx?type=1 发出请求并回显字符串,但是当在页面上使用上述代码时,我什么也得不到。

有什么办法可以做到这一点还是只是我滥用 PHP?

I have a php wordpress site that's running on IIS. I need to include, as part of that file, the response from a local ASP.NET page. PHP is reallly not my strongest language though.

The code I have is:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_SERVER['DOCUMENT_ROOT']+'/GetDesigns.ashx?type=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$localText = curl_exec($ch);
curl_close($ch);
echo $localText;
?>

Making a request to /GetDesigns.ashx?type=1 works from a browser and echos a string, but when the above code is used on the page, I get nothing.

Is there any way to do this or is it just me misusing PHP?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2024-10-10 06:13:19
$_SERVER['DOCUMENT_ROOT']

会给你一个文件路径。

请改用

"http://".$_SERVER['SERVER_NAME']

或 硬编码地址。

$_SERVER['DOCUMENT_ROOT']

will give you a file path.

Use

"http://".$_SERVER['SERVER_NAME']

or a hardcoded address instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文