Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只想读取一些长流开头的一些有限字符,但file_get_contents不支持查找操作,我必须首先读取整个流以提取字符串的所需部分substr。
file_get_contents
substr
由于我的资源有限,应用程序的速度非常重要,我怎样才能更有效地做到这一点?
根据您的配置,fopen可以解决问题。从该页面上的示例:
fopen
$handle = fopen("http://www.example.com/", "r");
然后您可以使用fread读取必要的字节数,然后将其关闭。
fread