Welcome to WebmasterWorld Guest from 126.96.36.199
Perhaps a one digit string in PHP only takes up 8 bits, but of course it's impossible to do maths with this, unless you keep using ord() to convert it to a number.
Actually, why can't programming languages in general work with arbitrary datatypes of the form (2^x), where each level x represents the 'next size up'? This way, one could store say... 3 bits to allow for numbers from 0-7, or something like 100 bits for super gigantic numbers. Even C doesn't allow this.
Yes, you could always cast a single digit as string and PHP will convert it on the fly for you. But it is always best to understand how String conversion to numbers [php.net] work in PHP first.
So somehow, unless something significant is already eating into that 8 megabyte to begin with (which I doubt), PHP manages to bloat each integer by 16 times. That's actually quite impressive.
Okay, so use chars you say? Well guess what? PHP's one character strings eat up just as much memory as ints! Cool huh?
Sorry, rant over :)
8MB really is not very much memory. It was back when PHP first joined the programming scene, but not anymore. For simple scripts, it is fine, but for other stuff, you really need more. I usually increase my default to about 24MB.