は私が読んで、文字列として画像を印刷する次のスクリプトを持っている:Node.js fs.readFile()はPHPのfile_get_contents()として機能しますか?
PHP:
<?php
echo file_get_contents("/path/to/small.png");
のNode.js:
var fs = require('fs')
var file = fs.readFileSync('/path/to/small.png', 'utf8');
console.log(file)
をしかし、文字列の出力の間に少し違いがあります2つのスクリプトで。私は、次の囲碁コードで同じことを試してみましたが、出力はPHPのと同じです:
package main
import (
"fmt"
"io/ioutil"
)
func main() {
buf, err := ioutil.ReadFile("/path/to/small.png")
if err != nil {
panic(err)
}
content := string(buf)
fmt.Println(content)
}
だから、誰もがなぜfs.readFile()は異なる挙動を示すないアイデアを得ましたか?
感謝。しかし、2つのスクリプトはまだ異なるバイトを出力します。 – memo