I see how WAMP does this, and I want to implement this technique to my website to get the image encryption from the database, basically what I’m doing so far; but whenever I echo out the base64 decode with the ‘EOFILE’ in the variable, the image results in errors.
BUT, whenever I only have the base64 decode echo without the ‘EOFILE’s added in the variable, the image shows.
My question is, is there a way to add a variable in the <<< EOFILE . $x . EOFILE;
OR it’s completely OK to not include the ‘EOFILE’s in the PHP code.
Here are some references:
WAMP, using the ‘EOFILE’ when assigning the encryption to the variable:
$pngPlugin = <<< EOFILE
//base64 encryption of the image
EOFILE;
What I’m trying, with no EOFILE:
//note that the file when uploaded will get base64_encode() to the DB
$test = file_get_contents('./image.png');
$test2 = base64_encode($test);
//then implemented this way on the page via the DB
header("Content-type: image/png");
echo base64_decode($test2);
Adding variables to the <<< EOFILE doesn’t really work for some reason, but is it really needed? I never used EOFILE in PHP before, and google didn’t really do anything good for me, but how important is it? Do I need to worry about it if I don’t have it included in my code?
Also, what is the ‘<<<‘ used for in PHP?
Thank you 🙂
The
EOFILEis an arbitrary identifier in the Heredoc syntax which is used to define string literals.You can choose any identifier, e.g.:
However, if you already have a variable containing base64 encoded data (such as from a database) you can simply do this: