4th May 2008 - 3 minutes read time
You will sometimes want to make sure that your code is a better hidden from the end user. For example, you might want to make sure that your database password files are completely hidden from prying eyes so that even if your web server is hacked your database server isn't also compromised.
Take the following code, which prints out "Hello world".
echo "Hello world";
You can encode this into meaningless text by using the base64_encode() function.
$code = base64_encode('echo "Hello world";');
This turns the $code variable into the following.
ZWNobyAiSGVsbG8gd29ybGQiOw==
Which can be run again by using the bade64_decode() function in conjunction with the eval() function.