Understanding Octal numbers in php?

Hello, I’m trying to work out octal numbers and it’s doing my head in. Now take the number 01234:

(8 ^ 3) = 512 # so: 1 x 512 = 512
(8 ^ 2) = 64 # so: 2 x 64 = 128
(8 ^ 1) = 8 # so: 3 x 8 = 24
(8 ^ 0) = 1 # so: 4 x 1 = 4

So 01234 in octal is 668

I then tried out working out 0755

(8 ^ 5) = ??? # so: Outputs some crazy number with + symbols?
(8 ^ 7) = ??? # so: Outputs some crazy number with + symbols?
(8 ^ 0) = 1 # so: 5 x 1 = 6

But it’s throwing up all kinds of crazy errors when I use a calculator and I know the answer should be 493?

I think i’ve got the wrong end of the stick on how to work these out - anyone help?

Thanks


Octal 0755
       
(8 ^ 3) = 512 # so: 512 x 0 =    0
(8 ^ 2) = 64  # so:   64 x 7 = 448
(8 ^ 1) =  8  # so:     8 x 5 =   40
(8 ^ 0) =  1  # so:     1 x 5 =    5

Answer:  493


Decimal 0755
       
(10 ^ 3) = 1000 # so: 1000  x 0 =    0
(10 ^ 2) =  100  # so:  100  x 7 = 700
(10 ^ 1) =   10   # so:   10  x 5 =   50
(10 ^ 0) =    1   # so:      1 x 5 =    5

Answer:  0755


<?php
echo octdec('0755');
?>

returns 493, what is your problem?

I then tried out working out 0755

(8 ^ 5) = ??? # so: Outputs some crazy number with + symbols?
(8 ^ 7) = ??? # so: Outputs some crazy number with + symbols?
(8 ^ 0) = 1 # so: 5 x 1 = 6

Shouldn’t that be:

(8 ^ 3) = 512 # so: 0 x 512 = 0
(8 ^ 2) = 64 # so: 7 x 64 = 448
(8 ^ 1) = 8 # so: 5 x 8 = 40
(8 ^ 0) = 1 # so: 5 x 1 = 5

448+40+5=493