Is it possible to use some php code in asp.net while using c# in background.
<%@ 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>
I would like to use php like this way. Which package should I install?
As far as it is concerned running PHP
projects under IIS
, it is possible to achieve, here is an answer on SO that might help in this regard.
But if you want to mix up ASP.NET C# and PHP code then I suppose it is not possible. The real question is, why on earth would you want to go this way? Is there something PHP can do and C# cannot? To me, C# seems way more elegant than PHP, why would you want to do it anyway?
As far as it is concerned being able to echo some data on front-end you can do that in C# like this (or using many other ways that might suit your scenario):
<%@ 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>
.CS
Code Behind:
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;
}
Power is in your hand, you can achieve anything using C# that you could've achieved using PHP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.