In a WordPress theme I have the following code, (including debug info):
echo strlen($op);
$s = strlen($op);
echo($s);
echo($op);
error_log("strlen $s");
If I get to the page with www.someurl.com I see 2525stringwith25chars on the screen and strlen 25 in the log.
If I go to the page with www.someurl.com/?lang=es I see 00 on the screen and strlen 25 in the log. It appears the echo isn’t echoing the variable for the new locale.
Turns out WP is passing through the code 3 times, the first time the results are correct and appear (or don’t) on the screen, but the 2nd and 3rd times the different results aren’t shown on the screen, only in the log, but so far up as to be invisible.
Solved using microtime() print out before and after the echo and before and after the log entry it became clear the log entries weren’t reflecting the echos.
As to why WP is passing through 3 times, with the 404 handler plugin installed, any unloadable image files (in the css for example) cause a 404 cause a redirect to the 404 error page.