Re: Newcomer, PHP pre-processing, Magic Constants __FILE__ and __LINE__ override with #line like in C
| From: | Levi Morrison via internals | Date: | Mon, 24 Oct 2022 23:44:25 +0000 |
| Subject: | Re: Newcomer, PHP pre-processing, Magic Constants __FILE__ and __LINE__ override with #line like in C | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118880@lists.php.net to get a copy of this message | ||
> I think you're also greatly over-estimating how large the startup cost is in practice.
> It's real, certainly, but unless you have several nested microservices a well-made framework
> should have a fairly small overhead.
I want to share my experience that some users have very slow file I/O,
and I regularly see
file_exists and stat show up in slow code
paths. This is one reason I would like to remove the warning on a
failed include, because then instead of `if (file_exists($file))
require $file; or similar, you can just include $file;` it. When I
brought it up last time, some people actually liked that it has
warnings so... I didn't move forward. Maybe there's room for
try_include:
[$included, $retval) = try_include($file);
if ($included) {
// $retval will have the return value of the file
} else {
// $retval will have a warning/error message you can work with
}
I like this quite a bit less than changing include to not emit a
warning, but it's not without merits:
1. include still emits a warning, so nobody relying on that will be
surprised.
2. User gets to control error handling.
3. Can be polyfilled, it just costs a bit of performance.
Anyway, it's a bit off topic, so I'll stop here.