从 ASP 翻译为 PHP
我被迫与一家仅支持 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
代码实例化类方法
ContentServer()
将类型 var state 显式为字符串,
在这里您将获取 REQUEST URI(如在 php 中)路径并将其转换为一行字符串并放入前面提到的字符串stette var
并在此处返回消息而不刷新页面(ajax)。
the code instantiates the class method
ContentServer()
Explicit the type var state as string
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
and here return the message without refresh the page (ajax).
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 usingRequest.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 thecs.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 theGetXhtml
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.
在 PHP 中它看起来像这样:
It would look like this in PHP: