一些 php 到 ASP.NET
有好心人可以将此 php 转录为 ASP.NET 吗?
预先感谢您。
jJ
<?php
if(isset($_POST['data']) && $_POST['data'] != '') {
$output = $_POST['data'];
$newfile = time() . ".xml";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file);
echo 'file created: ' . $newfile;
} else {
echo "not saved";
}
?>
anyone kind enough to transcribe this php to ASP.NET ??
thank you kindly in advance.
jJ
<?php
if(isset($_POST['data']) && $_POST['data'] != '') {
$output = $_POST['data'];
$newfile = time() . ".xml";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file);
echo 'file created: ' . $newfile;
} else {
echo "not saved";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未经测试的代码,但足以让你开始
这就是我学习 PHP 的方式,所以我觉得有义务回报:)
编辑:正如其他人所说,你当然不应该按原样使用它,而是用它来学习。
Untested code but enough to get you started
This was how I learned PHP so I felt obligated to pay back :)
Edit: As everyone else has said, you should of course don't use this as-is but instead use it for learning.
据我所知,这并不能像您可能想要的那样直接转换为一大块 ASP.NET 代码。
您需要一个 .aspx 文件,并且需要背后的代码(.aspx.cs 文件)以最基本的方式执行此操作。打开、写入和关闭文本文件可以像这样完成。其余部分依赖于特定的 ASP.NET 技术,例如使用
元素,然后检索后面的代码。您要求执行一项相当简单的任务,如果您花一些时间亲自了解 ASP.NET,您的情况可能会更好。
编辑:
@Jesper Palm 或多或少做了我所说的在我的第一行中不可能实现的事情。在我看来,ASP.NET 框架的使用无论如何都是奇怪的。 :-)
As far as I can see, this is not directly translateable to one chunk of ASP.NET-code as you'd probably want.
You need an .aspx-file, and you need the code behind (.aspx.cs-file) to do it in the most basic way. Opening, writing and closing a text file could be done like this. The rest relies on specific ASP.NET-techniques like using a
<asp:whatever id="data">
element and then retrieving this code behind.You're asking for a fairly simple task, and you would probably be better off if you took some time to look at ASP.NET yourself.
Edit:
@Jesper Palm did more or less what I said was not possible in my first line. Weird use of the ASP.NET framework anyways, in my opinion. :-)