2014-09-29 69 views
-3

我是一名前端开发人员,但我学习PHP,所以我可以做基本的后端的东西。我的代码似乎是在回显字符串之后加上字符数量。PHP字符串后字符数量

<?php 
    $openFile = fopen("file.txt","w"); 
    $name = "Chris"; 
    fwrite($openFile,$name); 
    fclose($openFile); 
    $openFile = fopen("file.txt","r"); 
    echo readfile("file.txt"); 
    fclose($openFile); 
?> 

这是我在这里发布的内容。 -2。

实时预览:http://icodewebsitesandineedatestingserver.netai.net/

+0

安置自己的代码,而不是在其他地方张贴和分享链接:

您可以使用file_get_contents。 – 2014-09-29 11:46:46

+0

向我们展示您的代码以及预期的输出和实际输出,以便我们可以为您提供帮助 – 2014-09-29 11:54:10

+0

每当我尝试使用stackoverflow时想要对其进行格式设置并在正确执行时仍然不会让我粘贴代码。 – Sokaz 2014-09-29 11:54:24

回答

1

我想你想读取文件的内容是什么?上的ReadFile

PHP DOC: Reads a file and writes it to the output buffer.

5是读的字节数。这里

<?php 
    $openFile = fopen("file.txt","w"); 
    $name = "Chris"; 
    fwrite($openFile,$name); 
    fclose($openFile); 
    echo file_get_contents("file.txt"); 
?> 
+0

最后!有人在这里,实际上是有帮助的! – Sokaz 2014-09-29 12:04:54