If there is a "success" response, does test.php close, thus when its called again, it loads wp-load.php again?
Exactly. The concept behind require_once
(or include_once
) is to make sure you don’t reload the same functions, classes & variables into the same currently running PHP code at the same time:
include_once
may be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, so in this case it may help avoid problems such as function redefinitions, variable value reassignments, etc.
And since PHP scripts run only on request, what you describe is exactly how it would happen.
That said, I wouldn’t over-think the concept of loading the whole wp.load
each time it’s needed. I doubt it will cause such a performance hit that it would even be noticeable.