FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » decode encoded url
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: decode encoded url [message #178699 is a reply to message #178689] Wed, 18 July 2012 08:29 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 17/07/2012 15:04, cerr escribió/wrote:
> On Tuesday, July 17, 2012 12:52:53 AM UTC-7, Álvaro G. Vicario wrote:
>> El 17/07/2012 7:47, cerr escribió/wrote:
>> > I have a url that refers to a css background like:
>> > url(./sites/all/themes/marinelli/img/backgrounds/men's_and_lad ys'_nights.jpg);
>> > But now I'm wondering how I possibly should name that file or how i can decode this string to a url the filesystem & the browser can read?
>>
>> If the string is supposed to be HTML, you need to convert it into plain
>> text. It can be extremaly tricky becase the two most obvious functions
>> don't seem to work as advertised:
>>
>> http://es.php.net/manual/en/function.html-entity-decode.php
>> http://es.php.net/manual/en/function.htmlspecialchars-decode.php
>>
>> Another alternative is to use mb_convert_encoding():
>>
>> <?php
>> $html =
>> 'url(./sites/all/themes/marinelli/img/backgrounds/men' s_and_ladys'_nights.jpg);';
>> var_dump(mb_convert_encoding($html, 'UTF-8', 'HTML-ENTITIES'));
>
> This doesn't work for me, I got some error:
> <b>Parse error</b>: syntax error, unexpected '=', expecting ')' in <b> /homepages/9/d412202464/htdocs/drupal-7.14/sites/all/themes/marinelli/templ ates/html.tpl.php </b> on line <b>17</b><br />

I wonder what code you are actually running, given that my snippet has
somehow grown HTML entities when you've quoted in your answer, but
that's a good old syntax error. Can't you really fix it?

>> If the string is supposed to be plain text already, I see no problem.
>
> It wouldn't link a file called
> men&#039;s_and_ladys&#039;_nights.jpg nor
> men's_and_ladys'_nights.jpg

I beg your pardon? If the string is plain text, you don't have single
quotes anywhere: you have literal & characters.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Always Outputs
Next Topic: PHP Rear End Data Developer/ Contract/ Boston area
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 03:46:17 GMT 2024

Total time taken to generate the page: 0.04568 seconds