不推荐使用PHP版本

时间:2019-02-22 20:35:27

标签: php

关于这两个功能的任何想法,由于PHP版本升级而停止工作

function read_str($fp)
{
   $strlen = $this->bin2dec(fread($fp, 4), 4);
   return fread($fp, $strlen);
}

function read_byte($fp)
{
  return $this->bin2dec(fread($fp, 1), 1);
}

还有我要解决的旧脚本。

服务器输出错误

“ [[22-Feb-2019 20:24:38 UTC] PHP严格标准:仅变量应在第2884行的/?中通过引用传递 [2019年2月22日20:24:38 UTC] PHP严格标准:仅变量应通过引用传递给/? 2860行 “

这是2个功能

    /*!
     * @function read_byte
     * @abstract Reads a byte from a file
     * @param fp  file pointer - pointer to an open file
     * @result the read byte as an int
     */
     function read_byte($fp)
     {
     return $this->bindec(fread($fp, 1), 1);
     }

     /*!
     * @function read_str
     * @abstract Reads a string from a file
     * @param fp  file pointer - pointer to an open file
     * @result the read string
     */
     function read_str($fp)
     {
     $strlen = $this->bindec(fread($fp, 4), 4);
     return fread($fp, $strlen);
     }

这是实际使用的文件,它正在调用上面的错误。

    <?php
    if(ereg("[a-zA-Z0-9]",$event))
    {

    //returns highest key in the database
    function getMaxKey($db) {

    $maxKey = 0;

    $sortby = "event_key";
    $result = $db->getall();

    foreach($result as $item){
       $key = $item["event_key"];
       if($key > $maxKey)
          $maxKey = $key;
    }

    return $maxKey;
    }

    // Include the FFDB library
    include("../ffdb.inc.php");

    //open db or create new db
    $db = new FFDB();
    if (!$db->open("../calendar"))
    {
       // Define the database shema.
       // Note that the "last_name" field is our key.
       $schema = array(
          array("_key", FFDB_INT, "key"),
          array("_name", FFDB_STRING),
          array(_year", FFDB_INT)
       );

       // Try and create it...
       if (!$db->create("calendar", $schema))
       {
          echo "Error creating database\n";
          return;
       }
    }

    //if no key file create a new one
    if(!file_exists("key.dat"))
    {
     $newKey = getMaxKey($db);
     $newFile = fopen("key.dat", "w") Or die("Can't open file");
     fwrite($newFile,$newKey);
     fclose($newFile);

    }

    //add a record
    //convert forms to record
     $fileread = fopen("key.dat", "r")Or die("Can't open file");
     $data = (int) fread($fileread, 10);
     fclose($fileread);
     $data++;
     $fileread = fopen("key.dat", "w") Or die("Can't open file");
     fwrite($fileread,$data);
     fclose($fileread);

     //add the record
     $record["_key"] = $data;
     $record["_name"] = ucwords($event);
     list($record["_year"]) = sscanf($year, "%d"); // string -> int

     // Add a _new_ entry
     echo("");
     if (!$db->add($record))
     echo("failed!\n");
     else {

     //table to display after adding
     $addedTable ="

谢谢

1 个答案:

答案 0 :(得分:-1)

错误已经说过了,您正在传递$ fp,这可能是通过打开二进制文件来实现的fsocketopen。

bin2dec是本地自定义私有函数,因为使用$ this->进行了调用。