PHP fscanf vs fgets

那年仲夏 提交于 2019-12-05 19:36:48

The PHP documentation of fscanf() and sscanf() is not complete. The formats are similar to the ones used by printf(), but they're not exactly the same. When you're printing, %s will print any string, but when you're scanning it just reads a word. To get more complete information, you need to read the documentation of the C fscanf() function. Some of this information is also in the comments section of the documentation web page.

To read a whole line with fscanf(), use "%[^\\n]". In fscanf(), $[^characters] means to match any sequence of characters that isn't in the set between the brackes (it's similar to [^characters]* in a regular expression). So this matches any sequence of characters other than newline. See http://php.net/manual/en/function.sscanf.php#56076

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!