C# 是否可以使用c在asp.net上运行php代码#
在后台使用c#时,是否可以在asp.net中使用一些php代码C# 是否可以使用c在asp.net上运行php代码#,c#,php,html,asp.net,C#,Php,Html,Asp.net,在后台使用c#时,是否可以在asp.net中使用一些php代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MeineWebseite.löschen.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="s
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MeineWebseite.löschen.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<?php
echo "Hallo \"Welt\"";
echo $name;
echo " - i'am feeling fine";
function ausgabe ($wert)
{
echo $wert;
}
?>
</form>
</body>
</html>
就在IIS
下运行PHP
项目而言,这是可能实现的,下面是一个关于这方面可能有所帮助的例子
但是如果你想把ASP.NETC#和PHP代码混在一起,我想这是不可能的。真正的问题是,你到底为什么要走这条路?有什么是PHP可以做而C不能做的吗?对我来说,C#似乎比PHP优雅得多,你为什么要这么做呢
就能够在前端回显一些数据而言,您可以用C#这样做(或者使用许多其他适合您场景的方法):
权力掌握在你手中,你可以用C实现任何你用PHP可以实现的事情。你试过吗?是的,我试过了!我试着用peachpie,但效果不太好,我想你不能把两种语言混在一起。对于初学者,选择一种语言并学习如何用它编写简单的程序。过一会儿,你可以看看其他语言,然后看看它们各自的优缺点。好的!我现在明白了。谢谢,现在很多人都在使用PHP,而且据我所知,它很容易使用。到目前为止,我一直在使用c#但我尝试随机显示文件夹中的图像,但我做不到,但我在互联网上看到了许多使用PHPY的示例。你也可以找到许多使用c#显示图像的示例。在万维网上有很多帮助的材料。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MeineWebseite.löschen.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Literal runat="server" ID="ltEchos"/> <!-- Would share a sample to use this control to populate things -->
</form>
</body>
</html>
public void EchoSomeDataWithResponseWrite()
{
Response.Write("Hallo \"Welt\""); // echo, that does not involves the Literal control
// to give a line break, put your html like below
Response.Write("<br />");
var name = "John Doe"; // to write name
Response.Write(name);
// to write some raw script:
Response.Write("<script>alert('Weather is fine today!')</script>");
}
public void EchoSomeDataWithLiteralControl()
{
var name = "John Doe";
var html = "Hallo \"Welt\" <br /> ";
html += name + "<br />";
ltEchose.Text = html;
}