I used php on my website so it can display multiple languages. I noticed the size of the html files reduced because most of the text was moved to a new large php file, which contains all "idiomatic" text in all languages available (just two in my case).
My problem is: Previously a html page was downloaded with just the necessary text. Now a smaller html page is downloaded but a large php file is always included, whether the html uses more or less lines of it.
Questions:
- When a php file is included (
include_once(file.php);orrequire_once(file.php);) what is happening? Is the content of thefile.phpbeing copied to the html? Is it just used to say to the language processor "If you need to resolve a name, you may want to look atfile.php"? - What is more (speed) efficient; to have one large php with every language of every html page inside; or to have one php file per html page only with the code needed by that page?
- Should a php be included right before being used, or should be a general include at the top of the page that gets most of the php that will eventually be used along the html page?
- Finally, does php increase a page loading time?
P.S: Anyone tried PHP Speedy? Does it really works? Does it have any problems (compatibility) ?
I found out:
- (check solution)
- Both solutions have exactly the same performance. I chose to separate the file by language because it feels tidier.
- Same as above, no impact on performance.