PHP Functions and server efficiency

This question already has an answer here:

  • When is optimisation premature? 20 answers

  • PHP has to parse the WHOLE file, creates some bytecode from it that represents the source code, and then executes that bytecode.

    It does not matter where you place your function - it will always be parsed and made into bytecode.

    Once it is bytecode, the execution path may differ, ie the function may not be called, but I fail to see that this makes anything but minor differences.

    All in all, you are asking about microoptimizations. If you can write code that clearly proves that one approach is better than the other, and that the speed differences are significant (ie they are more than 10% faster), and that the code readability is not significantly worse, you have a valid case.

    I don't think you have a valid case here. The function will get parsed independently of where it is placed, and executed only when the code path leads there.

    链接地址: http://www.djcxy.com/p/39566.html

    上一篇: 为什么String.equalsIgnoreCase太慢了

    下一篇: PHP功能和服务器效率