PHP rename all variables inside code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

PHP rename all variables inside code

I would like to rename all variables within the file to random name. For example his: $example = 'some $string'; function ($variable2){ echo $variable2; } foreach($variable3 as $key => $var3val){ echo $var3val."somestring"; } will become this: $frk43r = 'some $string'; function ($izi34ee){ echo $izi34ee; } foreach($erew7er as $iure7 => $er3k2){ echo $er3k2."some$string"; } It doesn't look so easy task so any suggestions will be helpful.

30th Nov 2016, 10:01 PM
Hooman Hassanzadeh
Hooman Hassanzadeh - avatar
1 Answer
- 1
I believe you're referring to code obfuscation. There should be a program out there that can do that automatically, but you could always just open the PHP file up in a good text editor and find/replace for each variable if there aren't too many...
30th Nov 2016, 11:09 PM
Brooklyn
Brooklyn - avatar