0

为什么每次执行此代码都会在a.txt中添加两个点到数字

<?php

function substr_unicode($str, $s, $l = null) {
    return join("", array_slice( preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY) , $s, $l) );
}

function statusRead() {
    $statusfile = file_get_contents('a.txt');

    // for detecting and removing BOM (0xEF,0xBB,0xBF)
    $statusfile = ord($statusfile[0]) == 239 ? ord($statusfile[1]) == 187 ? ord($statusfile[2]) == 191 ? substr_unicode($statusfile, 1) : $statusfile : $statusfile : $statusfile;

    $statusfile = str_replace("\r",'',$statusfile);
    $statusfile = explode("\n",$statusfile);
    foreach ($statusfile as $a) {
        $a = explode(":",$a);
        if($a[0]) $temp[$a[0]] = @$a[1] ? $a[1] : null;
    }
    return $temp; // changed: (($statusfile = $temp; return $statusfile;)) to ((return $temp;))
}

function statusUpdate($data) {
    $temp = '';
    foreach ($data as $a => $b) {
        $temp .= "$a:$b\r\n";
    }
    file_put_contents('a.txt', $temp);
}

$a = statusRead();
$a['number']++;
statusUpdate($a) ;
?>

这是a.txt的内容:

stop:0    
number:5
dor:3

a['number']++每次给a.txt中的数字加两点,使用时给a.txt中的数字加4 点a['number'] += 2

更新:我更改$temp .= "$a:$b\r\n";$temp .= "$a :$b\r\n";并将我的数据保存在此结构中:

stop  :0    
number  :6
dor  :3
number :1

但为什么?

4

1 回答 1

0

最后我的问题解决了。

我在 chrome 上有两个扩展,这导致了这个问题。

1- Web 服务器通知程序

2- 网络技术通知者

禁用这两个扩展后,我的问题解决了。

我从这个页面找到了我的答案: php mail duplicates

于 2013-07-21T22:14:39.093 回答