Using PHP I want to do millions of 2^n exponentiation but so far I only got up to n^1023 before PHP printed INF.
Any ideas?
You can use the BC Math functions:
$num = bcpow(2, 1000000); // Takes a few seconds to run!
As Greg said, BC Math is fine, but if you really need efficiency, try GMP instead.