How can i get the size a var is using in the buffer?
Are you looking for something like [man]strlen/man, [man]count/man or [man]filesize/man?
filesize doesnt bring me anything because its a string and i dont want to save it. Strlen only gives me the number of charackters in a string.
I want to know the size in bytes of a string. help me please.
well if count() isnt good enough then you could always try something like
function memsize($str) { return strlen($str)*8; //return size of $str in bits, based on 8 bits per character in most fonts (then again I could remember my math wrong it is 5am after waking up at 8am...) }
I thought about that too? But what about when the fontsize and type differs each time in the var?
vars dont store font sizes....
as for types... well not much you can do.... count() might work but no gaurantuees
fontsize?
What has that got to do with strlen() ?
if you know the number of characters, and 1 character is 1 byte, assuming you discount a '\0' character at the end of the string, then the number of bytes equals the number of characters.
.. too write the var in a textfile then open the textfile and gets its size over filesize. Dirty but must work.
use strlen... if a string has 15 characters then the size is just that, 15 bytes.
Originally posted by orsch .. too write the var in a textfile then open the textfile and gets its size over filesize. Dirty but must work.
filesizes are not always accurate either...