2011-01-31 43 views
1

我被迫與僅支持ASP.NET的數據庫公司合作,儘管我的僱主非常清楚我只使用PHP編碼,而且項目沒有時間學習新的句法。從ASP翻譯爲PHP

文檔很少,而且意義不大。有人可以幫忙翻譯一下此腳本中發生的事情,讓我可以考慮一下在PHP做

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

回答

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

代碼實例化類方法ContentServer()

string state = ""; 

顯式類型VAR狀態作爲字符串

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

在這裏你得到了REQUEST URI(如在php中)路徑並將其轉換成一個線串,把在之前提到的字符串斯塔泰VAR

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

這裏不刷新頁面(AJAX)返回的消息。

+0

是什麼ContentServer()呢? – 2011-01-31 16:36:13

0

Request對象封裝了一系列關於來自客戶端的請求的信息,即瀏覽器功能,表單或查詢字符串參數,cookie等。在這種情況下,它用於使用Request.Url.AbsoluteUri.ToString()來檢索絕對URI。這將是完整的請求路徑,包括域,路徑,查詢字符串值。
對象Response將從服務器發送回來的響應流包裝回客戶端。在這種情況下,它被用於將作爲響應主體的一部分的cs.GetXhtml(state)調用返回給客戶端。
QES.ContentServer似乎是第三方類,不屬於標準.NET框架的一部分,因此您必須訪問特定的API文檔才能找到GetXhtml方法的具體用途和用途。

所以,簡而言之,這個腳本從客戶端獲取請求的完整URI並將GetXhtml的輸出返回給響應。

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. 
?>