I was wondering if there was a programmatic reason why php developers chose to not have preg_match return data.
I’m mainly wondering if it is faster to reference variables that don’t exist instead of returning values?
Or is this just one of those “its just the way the function was implemented” issues?
I appreciate your time, ty.
Doing it this way avoids needless string buffer copying when the actual captured substrings are not used; depending on the string sizes, this can be a substantial waste of resources.
When the
$matchesargument is not passed, PHP can determine whether to allocate resources for it or not. The same can’t be done for the return value, becausepreg_match()is typically used inside a condition which needs to evaluate it.