Jump to content

Recommended Posts

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

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

 

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.

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.