Does a variable name length matter for performance in PHP?

I saw this thread of variable length for C # performance? and has the same question about php.

My employee (Front-end) was encoded just like $ o, $ r, $ x, $ m, $ c and motivated him with better performance. I really really doubt it, and the code has become hard to read.

  • $ o - object or object
  • $ m - $ model
  • $ r - $ query_result or $ result
  • $ x - $ xml_node

Every thing looks like

if ( isset ( self::$o[ self::$x -> name ] ) ) : $c = 'ClassPrefix_' . self::$o[ self::$x -> name ]; $o = new $c; self::$x -> read ( ); 
+6
source share
2 answers

Variable names exist more like a programmer's assistant - when a program or script is interpreted, they are converted to memory cells. Shorter variables will only negatively affect the performance of the programmer (s) when changing / debugging code in the future.

Obfuscation is a widely used method that involves replacing variable names with single / multi-character variable names, but this is used in an attempt to reverse engineer / raise the underlying technology from projects where the source code is easily accessible / easily extracted more complicated.

+7
source

While it can store bytes here and bytes, no, it does not matter for iota, and you will not see real memory or performance savings using short variable names.

If you are really concerned about memory usage and performance, please comment on your code. xdebug and xhprof are great tools for getting this done. You can even install xhprof on your production machines. Once you have truly measured your performance and memory usage, you can tune the real problems in your code.

Also, make sure you use 5.4 if you can. It introduces some huge improvements in both performance and memory usage.

+5
source

All Articles