Many notations use "^" as a power operator, but in PHP (and other C-based languages) that is actually the XOR operator. You need to use this 'pow' function, there is no power operator.
i.e. 3^2 means "3 XOR 2" not "3 squared".
It is particular confusing as when doing Pythagoras theorem in a 'closet points' algorithm using "^" you get results that look vaguely correct but with an error.