tastro Posted May 8, 2012 Share Posted May 8, 2012 hi, would that work? html_entity_decode($string,ENT_QUOTES|ENT_HTML5|ENT_HTML401|ENT_XML1|ENT_XHTML,'UTF-8') or must i use it like that? html_entity_decode($string,ENT_QUOTES|ENT_HTML5,'UTF-8') best regards, tastro Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/ Share on other sites More sharing options...
Andy-H Posted May 8, 2012 Share Posted May 8, 2012 I'm pretty sure you can use as many as you want, I think it works like this: define('ENT_QUOTES', 1); // binary 10000 define('ENT_HTML5', 2); // binary 01000 define('ENT_HTML401', 4); // binary 00100 define('ENT_XML1', ; // binary 00010 define('ENT_XHTML', 16); // binary 00001 Then when you bitwise or them, it results in: ENT_QUOTES (1) | (10000) ENT_HTML5 (2) | (01000) (11000) ENT_HTML401 (4) | (00100) (11100) ENT_XML1 ( | (00010) (11110) ENT_XHTML (16) | (00001) (11111) Then in the PHP core: int flags = arg[1]; if ( flags & 1 ) // ENT_QUOTES ON if ( flags & 2 ) // ENT_HTML5 ON if ( flags & 4 ) // ENT_HTML401 ON if ( flags & 8 ) // ENT_XML1 ON if ( flags & 16 ) // ENT_XHTML ON Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344049 Share on other sites More sharing options...
tastro Posted May 8, 2012 Author Share Posted May 8, 2012 that's the problem... i don't know if one flag can overwrite another flag or not... so i don't know if i should use only one or all... but i need all, because if it's only 1 than it's useless to me. the problem is that i copy text from more different sources and some are html and some are html401 and some xhtml. it would be nice if someone would know it 100% that i can use all at once. i can't find any help for that on php.net thanks for your contribute Andy-H Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344050 Share on other sites More sharing options...
Andy-H Posted May 8, 2012 Share Posted May 8, 2012 Yes it will work, just looked and the documentation (html_entity_decode) states that the flags create a bitmask (see Wikipedia), this works as I previously explained. Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344051 Share on other sites More sharing options...
tastro Posted May 8, 2012 Author Share Posted May 8, 2012 although i think that you are right, something doesn't make sense for me. for example, if i would put this two flags together: ENT_QUOTES and ENT_NOQUOTES which one would be applied then? thank you for helping me. Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344063 Share on other sites More sharing options...
ManiacDan Posted May 8, 2012 Share Posted May 8, 2012 for example, if i would put this two flags together: ENT_QUOTES and ENT_NOQUOTES which one would be applied then? Why would you do that? Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344068 Share on other sites More sharing options...
tastro Posted May 8, 2012 Author Share Posted May 8, 2012 i wouldn't. but the possibility is there. anyways... i think that i got my answer. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344072 Share on other sites More sharing options...
Andy-H Posted May 8, 2012 Share Posted May 8, 2012 Let's find out: var_dump(ENT_COMPAT); var_dump(ENT_QUOTES); var_dump(ENT_NOQUOTES); var_dump(ENT_HTML401); var_dump(ENT_XML1); var_dump(ENT_XHTML); var_dump(ENT_HTML5); // output int(2) int(3) int(0) int(0) int(16) int(32) int(48) DOUBLE QUOTES SINGLE QUOTES ENT_NOQUOTES = 0 0 ENT_COMPAT = 0 1 ENT_QUOTES = 1 1 ENT_HTML401 = 0000 00 ENT_XML1 = 0000 10 ENT_XHTML = 0000 01 ENT_HTML5 = 0000 11 Judging from that I think I was wrong with what I previously said, it looks possible that you should only use one quotes flag and one DOCTYPE flag per call. Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344074 Share on other sites More sharing options...
salathe Posted May 8, 2012 Share Posted May 8, 2012 i don't know if one flag can overwrite another flag or not... Yes, when used incorrectly, flags can overwrite one another. For example, ENT_QUOTES|ENT_NOQUOTES is identical to ENT_QUOTES. the problem is that i copy text from more different sources and some are html and some are html401 and some xhtml. The document type flags are not related to the input document, but the type of entity or conversion used for the returned string. They're there to ensure that the returned value from the function is suitable for output in that document type. i need all, because if it's only 1 than it's useless to me. You should not be using all available flags at the same time. Use at most one flag from each group that has multiple choices. Quote handling (choose one) ENT_COMPAT ENT_QUOTES ENT_NOQUOTES Document type (choose one) ENT_HTML401 ENT_XML1 ENT_XHTML ENT_HTML5 Mix and match any/all of these ENT_IGNORE (don't use this) ENT_SUBSTITUTE ENT_DISALLOWED Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344075 Share on other sites More sharing options...
tastro Posted May 9, 2012 Author Share Posted May 9, 2012 thanks to both Andy-H and salathe! i will use html5 and no quotes. hope that it will do enough. thread solved. best regards, tastro Quote Link to comment https://forums.phpfreaks.com/topic/262264-how-many-flags-can-i-use-with-html_entity_decode/#findComment-1344149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.