I have a doubt that makes me very confused, it's about require_once
. I saw a question on StackOverflow about it but I'm still not sure I understand...
I know the difference between require and include is that using require, the script will issue a fatal error and stop execution, while include does not. But there is something that I have been asking myself, the true meaning of _once
, most people say something like: PHP will check if the file has already been included, and if so, not include (require) it again.
How will the script be required only once? I don't understand this, because in my point of view PHP scripts are not like CSS that our browser downloads and is saved on the machine, so then not needing to download again, I think that every time a PHP script is executed, it will do its job again, there is no way to understand that it has already been required just as browsers understand that we have already downloaded CSS files.
What is the real meaning of _once
? And could someone please give me an example, because I don't really understand it, I'm a beginner, I don't even know if I'm asking a proper question
If possible demonstrate some code so that I finally understand