Home > Backend Development > PHP Tutorial > 文件读取有关问题

文件读取有关问题

WBOY
Release: 2016-06-13 10:01:06
Original
764 people have browsed it

文件读取问题
问题大致是这样的:我在一个记事本文件里写了两行文字,admin和amdin,在php读取t_id=fgets($fp);$t_pwd=fgets($fp),和我自己定义的两个变量:$p_id= "admin ",$p_pwd= "admin "进行比较老是不相等,后来我想可能是fgets()函数读回的字符串带上后面的 '\n '的(至少c里是这样的),如果是真这样,请问有什么办法去掉后面带着的 '\n ',当然也可能不是这样的,请大家帮我解决一下困惑

------解决方案--------------------
如果是 'amdin '笔误,trim()一下就行了.
------解决方案--------------------
trim()
可以去掉
------解决方案--------------------
恩,可能有空格什么的
------解决方案--------------------
chop() 或 trim()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template