从 ASP 翻译为 PHP

发布于 2024-10-15 06:37:01 字数 319 浏览 5 评论 0原文

我被迫与一家仅支持 ASP.NET 的数据库公司合作,尽管我的雇主很清楚我只使用 PHP 编写代码,而且该项目没有时间学习新语法。

文档很少,而且意义也很薄弱。有人可以帮助翻译这个脚本中发生的事情,以便我可以考虑用 PHP 来做它

<%
 QES.ContentServer cs = new QES.ContentServer();
 string state = "";
 state = Request.Url.AbsoluteUri.ToString();
 Response.Write(cs.GetXhtml(state));
%>

I am being forced to work with a database company that only support ASP.NET, despite my employers being well aware that I only code in PHP and the project doesn't have the time to learn the new syntax.

Documentation is scant, and meaning in thin on the ground. Can someone help translate what is happening in this script, so that I can think about doing it in PHP

<%
 QES.ContentServer cs = new QES.ContentServer();
 string state = "";
 state = Request.Url.AbsoluteUri.ToString();
 Response.Write(cs.GetXhtml(state));
%>

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

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

发布评论

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

评论(3

神妖 2024-10-22 06:37:01
QES.ContentServer cs = new QES.ContentServer();

代码实例化类方法 ContentServer()

string state = "";

将类型 var state 显式为字符串,

state = Request.Url.AbsoluteUri.ToString();

在这里您将获取 REQUEST URI(如在 php 中)路径并将其转换为一行字符串并放入前面提到的字符串stette var

Response.Write(cs.GetXhtml(state));

并在此处返回消息而不刷新页面(ajax)。

QES.ContentServer cs = new QES.ContentServer();

the code instantiates the class method ContentServer()

string state = "";

Explicit the type var state as string

state = Request.Url.AbsoluteUri.ToString();

here you get the REQUEST URI (as in php) the path and convert it to one line string and put in the before mentioned string statte var

Response.Write(cs.GetXhtml(state));

and here return the message without refresh the page (ajax).

皇甫轩 2024-10-22 06:37:01

Request 对象包装了有关客户端请求的一堆信息,即浏览器功能、表单或查询字符串参数、cookie 等。在本例中,它用于使用 Request 检索绝对 URI .Url.AbsoluteUri.ToString()。这将是完整的请求路径,包括域、路径、查询字符串值。
Response 对象包装从服务器发送回客户端的响应流。在本例中,它用于将 cs.GetXhtml(state) 调用的返回结果写入客户端,作为响应正文的一部分。
QES.ContentServer 似乎是第三方类,并且不是标准 .NET 框架的一部分,因此您必须访问特定的 API 文档才能了解其用途以及>GetXhtml 方法确实如此。

因此,简而言之,该脚本从客户端获取请求的完整 URI,并在响应中返回 GetXhtml 的输出。

The Request object wraps a bunch of information regarding the request from the client i.e. Browser capabilities, form or querystring parameters, cookies etc. In this case it is being used to retrieve the absolute URI using Request.Url.AbsoluteUri.ToString(). This will be the full request path including domain, path, querystring values.
The Response object wraps the response stream sent from the server back to the client. In this case it is being used to write the return of the cs.GetXhtml(state) call to the client as part of the body of the response.
QES.ContentServer appears to be a third party class and is not part of the standard .NET framework so you would have to get access to the specific API documention to find out what is for and what the GetXhtml method does exactly.

So, in a nutshell, this script is taking the full URI of the request from the client and returning the output from the GetXhtml back in the response.

别靠近我心 2024-10-22 06:37:01

在 PHP 中它看起来像这样:

<?php
     $cs = new QES_ContentServer(); //Not a real php class, but doesn't look like a native ASP.NET class either, still, it's a class instantiation, little Google shows it's a class for Qwam E-Content Server.
     $state = "";  //Superfluous in PHP, don't need to define variables before use except in certain logic related circumstances, of course, the ASP.NET could have been done in one line like "string state = Request.Url.AbsoluteUri.ToString();"
     $state = $_SERVER['REQUEST_URI'];  //REQUEST_URI actually isn't the best, but it's pretty close.  Request.Url.AbsoluteUri is the absolute uri used to call the page. REQUEST_URI would return something like /index.php while Request.Url.AbsoluteUri would give http://www.domain.com/index.php
     //$state = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; or something similar might be better in this case given the above
     echo $cs->GetXhtml($state);  //GetXhtml would be a method of QES.ContentServer, Response.Write is like echo or print.
?>

It would look like this in PHP:

<?php
     $cs = new QES_ContentServer(); //Not a real php class, but doesn't look like a native ASP.NET class either, still, it's a class instantiation, little Google shows it's a class for Qwam E-Content Server.
     $state = "";  //Superfluous in PHP, don't need to define variables before use except in certain logic related circumstances, of course, the ASP.NET could have been done in one line like "string state = Request.Url.AbsoluteUri.ToString();"
     $state = $_SERVER['REQUEST_URI'];  //REQUEST_URI actually isn't the best, but it's pretty close.  Request.Url.AbsoluteUri is the absolute uri used to call the page. REQUEST_URI would return something like /index.php while Request.Url.AbsoluteUri would give http://www.domain.com/index.php
     //$state = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; or something similar might be better in this case given the above
     echo $cs->GetXhtml($state);  //GetXhtml would be a method of QES.ContentServer, Response.Write is like echo or print.
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文