Same Javascript code, unique outputs with PHP
I have the following Javascript:
<script>
function myFunction() {
document.write("Hello StackOverFlow users!");
}
myFunction();
</script>
Is any recommended/fast way to encode/encrypt/minify/pack the JavaScript using PHP so the output be different every time (using a random string to pack the js or anything similar)?
I just want the same function, that would do the same thing every time but with different JavaScript code each time.
Answer
Solution:
As most packers/compressors always use the same algorithm without any seed you might try to add some random js garbage before and after the function itself.
Answer
Solution:
Create random string function in PHP
Then modify your js function as follow
This will allow you to write random string each time JS function is called
[PHP function taken from 'https://www.xeweb.net/2011/02/11/generate-a-random-string-a-z-0-9-in-php/']