I’m making a push notification server that gathers specific data from an external (third-party) html page, if I know the information I need is within the first e.g. 5000 characters, will PHP actually use less memory if I state a MAX_LENGTH? Or is the whole page loaded entirely into memory anyway? Additionally, is the entire html page downloaded or is the connection broken once the limit is hit? (and in turn saving data transfer costs)
$html = file_get_contents ("http://.....", false, null, -1, 5000);
thanks.
Yes, it does save memory and bandwidth… I also ran a speed test (which is not completely germane to this question, but is useful and suggests that it does stop reading the stream) and a memory test just to demonstrate. I did not run a peak memory test, but at the very least your $html variable will store less information and save memory there.