1

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

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

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

3 回答 3

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

代码实例化类方法ContentServer()

string state = "";

将类型 var state 显式为字符串

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

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

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

在这里返回消息而不刷新页面(ajax)。

于 2011-01-31T16:33:17.513 回答
0

在 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.
?>
于 2011-01-31T17:28:36.717 回答
0

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

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

于 2011-01-31T16:44:35.173 回答