Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is using a PHP Function Alias poor performance/Bad practice?

Just out of curiosity,

Does the alias of a built-in PHP function take any more power than the regular function itself.

AKA, does sizeof() take more time than count() to run?

Note to Micro-Optimization Police: Unless there is a HUGE difference, I don't plan on trying to micro-optimize my script. Was just curious.

Note to the 'Just try it yourself' Police: I'm not able to access a PHP environment right now.


It seems that this has also expanded to a 'Best Pratice', as PHP's documentation states that aliases are best not used, and in turn should simply be called via the master function. In this case, that would mean that count() should be used over sizeof().

like image 707
Tyler Carter Avatar asked Sep 27 '26 16:09

Tyler Carter


1 Answers

I'm quite sure that they compile to the same byte-code equivalents, so the answer will be no.

like image 195
troelskn Avatar answered Sep 30 '26 05:09

troelskn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!