Search code examples
opencarthtmlspecialchars

Resolving HTML special chars in OpenCart


I've looked around for a solution to this problem but I can't find one. I am trying to make a payment method for opencart.

I have two fields(ID and key) set in the admin area which I then proceed to retrieve from controller of the front end page

(using this->config->get)

These fields are used to carry out encryption in a separate PHP file.

(Passing these as arguments)

However one of the compulsory fields (Key) has an '&' which is converted to '& amp ;' I used

htmlspecialchars_decode

Function to get rid of this and any other html char problems that I might face.

But I am still not getting the correct encryption. I cross checked by directly sending the key as string instead of using this->config->get.

Any thoughts and help? Thanks!


Solution

  • You could simply use str_replace() to convert the & back to & as you retrieve it in the controller

    <?
    // REPLACE VAR
    $string=str_replace("&amp;", "&", $data);
    ?>