as my webprojects are getting bigger I wonder if PHP interprets this code,
<?php
function helloWorldOutput($helloworldVariable) {
echo 'Hello World' . $helloworldVariable;
}
helloWorldOutput("I am PHP");
?>
slower than this:
<?php
function a($b) { echo 'Hello World'+$b; }
a("I am PHP");
?>
Because PHP is an interpreted language without compiled binary I think the second sample should be a bit faster. Is that true, and is there any kind of pre-interpreting mechanic which caches a faster version of the code in PHP?
Yes, it will take some extra time to parse/compile the larger code to byte code. The time is usually negligible, so you should probably just not worry about it since there are better ways to deal with the time spent compiling.
What you would do for quite a bit more performance boost, is to use a PHP accelerator like for example APC that will cache compiled code and eliminate the whole compile step except for at the first access to a page.
Using an accelerator will remove any possible downside with keeping your code commented and clear, and lets you concentrate on functionality instead of shortening your code.