所有的鸟儿他们都知道, 他们的巢应该筑在什么地方, 鸟儿知道自己该在什么地方筑巢, 那就意味着他们了解他们自己的使命。 我们身为万物之灵的人类, 怎么会不知道,连鸟儿都知道的道理呢?
从读取文本文件说php 和 C#
从读取文本文件说php 和 C#

从读取文本文件说php 和 C#

我总算知道为什么java在web方面干不过php了。

php就是简单得好,在这个追求开发效率而不是程序运行效率的年代,php就一个函数 file_get_contents — Reads entire file into a string
再看看msdn里面的c#


using System;

using System.IO;
public class TextFromFile
{
private const string FILE_NAME = "MyFile.txt";
public static void Main(String[] args)
{
if (!File.Exists(FILE_NAME))
{
Console.WriteLine("{0} does not exist.", FILE_NAME);
return;
}
using (StreamReader sr = File.OpenText(FILE_NAME))
{
String input;
while ((input=sr.ReadLine())!=null)
{
Console.WriteLine(input);
}
Console.WriteLine ("The end of the stream has been reached.");
sr.Close();
}
}


太过繁琐,不如php的简练。所以我发现自己还是喜欢php多一点。除非是很关心运行效率的地方。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注