How to setAttribute of DOMDocument element with special characters?
https://stackoverflow.com/questions/37174897/how-to-setattribute-of-domdocument-element-with-special-characters
Last updated
https://stackoverflow.com/questions/37174897/how-to-setattribute-of-domdocument-element-with-special-characters
Last updated
Ask QuestionAsked 4 years, 11 months agoActive 3 months agoViewed 2k times3
In an HTML block such as this:
I need to transform the URL src
of the image to a Laravel storage_path
link. I'm using PHP DOMDocument to transform the url like so:
The problem is that the output is src="%7B%7B%20storage_path('app/'%20.%20foo.png)%20%7D%7D"
How can I keep the special characters of the src
attribute?phpdomdocumentsetattributeShareImprove this questionFollowasked May 11 '16 at 23:31greener4,7351010 gold badges4545 silver badges8383 bronze badges
Are you going to close this answer too ? – Pedro Lobito May 11 '16 at 23:32
@PedroLobito if by answer you mean question, yes I would if I find a duplicate on SO before anyone answers.. is that not expected? – greener May 11 '16 at 23:38
That looks like URL encoding. I would be surprised if DOMDocument does this. Is there something else that might decide 'src' needs to be url encoded? – Halcyon May 11 '16 at 23:49
You can use something like: