什麼是C#相當於include函數在PHP?我有下面的代碼在PHP轉換爲C#轉換的代碼PHP到C#
if (file == "") file = str_replace(" ", "", family).strtolower(style) + " +ok sir php";
if (defined("FPDF_FONTPATH"))
file = FPDF_FONTPATH + file;
include(file);
什麼是C#相當於include函數在PHP?我有下面的代碼在PHP轉換爲C#轉換的代碼PHP到C#
if (file == "") file = str_replace(" ", "", family).strtolower(style) + " +ok sir php";
if (defined("FPDF_FONTPATH"))
file = FPDF_FONTPATH + file;
include(file);
有在C#中沒有相應的 - 你不能動態包括:一個文件到你的源代碼中。
在C#中重用代碼的方法是使用控件。當你問到PHP時,我認爲你的意思是ASP.NET而不是Winforms或WPF,所以你需要創建user controls or custom controls,你可以在你的網站中重用。
我用來從另一臺服務器「包含」菜單文件的一些代碼。
if (Application["menu"] != null)
{
litMenu.Text = Application["menu"].ToString();
}
else
{
try
{
System.Net.WebRequest wrq = System.Net.WebRequest.Create(ConfigurationManager.AppSettings["MenuPath"]);
System.Net.WebResponse wrp = wrq.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(wrp.GetResponseStream());
litMenu.Text = sr.ReadToEnd();
Application["menu"] = litMenu.Text;
}
catch
{
Application["menu"] = litMenu.Text;
}
}
目標是讓我們的Intranet(PHP)和管理後端(ASP.NET)看起來像是同一個系統。
恐怕唯一的解決辦法是「用你的赤手空拳」 – Natrium 2010-02-10 08:32:18