警告:fflush()需要1个参数,给定0

时间:2014-04-30 20:18:00

标签: php mysql

您好我需要在install.php中使用此代码的一些帮助,该代码必须先在程序之前运行,但是它会指向fflush上的错误我不知道该怎么办请帮忙吗?

    <?php
        fflush();

      authTableCreate();
      announceTableCreate();
      classTableCreate();
      studentTableCreate();
      classmembersTableCreate();
      attendanceTableCreate();
      assignmentTableCreate();
      messageTableCreate();
      supportTableCreate();


      if (!authCheckUserExists('admin')) { // this is their first install probably
          $randpass = 'admin' . mt_rand();
          authAddUser('admin', $randpass, 100, 100);   // create default superuser account
          announceAddAnnouncement('Welcome', 'This is the default start page for IntraSchool.  You should change this to something that describes how the system works within your school.');
    ?>  

    <p>Congratulations!  You have successfully setup <em>IntraSchool</em>.  You may now <a href="login/login.php">login</a> with the username <em>admin</em> and password <em><?=$randpass?></em>.  Please change the password to something you can remember.</p>

    <?php
      } else {
    ?>

    <p>The installation script has reinitialized any deleted tables.</p>

    <?php
      }

      page_footer();
    ?>

2 个答案:

答案 0 :(得分:1)

fflush()需要刷新文件的句柄。它可能是flush()的拼写错误,但是因为它显然在文件的开头根本不会做任何事情。你应该删除该行。

它只是一个警告,所以脚本的其余部分可能已被执行。如果它是一次性设置脚本,那么您可能不需要再次运行它。

答案 1 :(得分:0)

这是the documentation - 一直是个好地方。

我对你的代码的理解是有限的,所以我不确定你在这里想要完成什么(特别是,看起来你正在做数据库操作,因为fflush不需要)。也就是说,这里有一点背景:

fflush将打开的文件刷新到磁盘。你需要为它提供一个文件句柄来刷新。

当您写入磁盘上的文件时,操作系统通常会存储一堆数据并将其全部写入磁盘,而不是在发送时写入每个字节。这主要是出于性能原因。但是,有时您需要在程序中的特定位置写入数据。这就是fflush的用途。但是要使fflush起作用,你需要告诉它你正在谈论的文件 - 这是文档中提到的文件句柄。