I was listening to a Zend webinar on PHP optimization, and one point I took note of was that the require_once statement should be avoided as it is considered expensive. I realize that this could be controversial, and my question is not specifically about this point.
In looking at our codebase to see how prevalent require_once might be, I was glad to see very few instances of it, and even those were not necessary. However I got to a library that was added by one of our programmers who is no longer with us, and I found some code which at first glance looks puzzling.
The library is called HTTP_FloodControl and was written by Vagharshak Tozalakyan. We use it to prevent flooding attacks, which in the past we suffered from time to time.
An extract of the code showing the "recursive" include from the script MDB.php follows:
Note: the script is in the file MDB.php and the require statement includes MDB.php.
My understanding of this construct is that the require_once for MDB.php being self-referential would lead to an infinite recursion, except possibly for the fact that it has the "_once" part, which prevents this from occurring. Thus I am concluding that this code is present for documentation purposes. And if so it could be commented out.
Am I misinterpreting the intent of this code?