dpzff20644 2013-10-09 12:48
浏览 24
已采纳

从非txt fopen文件创建文本框

I have the following code that opens a non-txt file and runs through it so it can read the file line by line, i want to create a textbox (using html probably) so i can put my readed text into that but i have no idea how to do it

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <h2>testing</h2>
        <?php
        $currentFile = "pathtest.RET";
        $fp = fopen($currentFile , 'r');
        if (!$fp)
        {
            echo '<p> FILE NOT FOUND </p>';
            exit;
        }
        else
        {
            echo '<p><strong> Arquivo:</strong>  ['. $currentFile. '] </p>';
        }

        $numLinha = 0;
        while (!feof($fp))
        {
            $linha = fgets($fp,300);
            $numLinha = $numLinha + 1;
            echo $linha;
        }      
        fclose($fp);
        $numLinha = $numLinha -1;
        echo '<hr>linhas processadas: ' . $numLinha;
        ?>
    </body>
</html>

i need the textbox area to be in a form so i can define the cols and rows, or there is an way to do it in php ? is there any way to send the readed content to another .php so i can edit the php to an html interface style freely ?

  • 写回答

1条回答 默认 最新

  • douhao7889 2013-10-09 12:51
    关注

    Try echoing the lines between a textarea:

    echo "<textarea>";
    
    while (!feof($fp))
    {
        $linha = fgets($fp,300);
        $numLinha = $numLinha + 1;
        echo $linha;
    };  
    
    echo "</textarea>";
    

    You may use in order to break lines on the textarea:

    echo $linha . "
    ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)