I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?



I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, ..

Answer / Sukveer Singh Aswal

The issue is that the sequence 0123 is treated as an octal (base-8) number in PHP. To assign the decimal (base-10) value of 123 to a variable, use '0123' enclosed in quotes:

```php
$myVar = '0123';
echo $myVar; // outputs 123
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What is nan value?

1 Answers  


What does $_ post mean in php?

1 Answers  


Can anyone explain about join?

3 Answers  


What is php key?

1 Answers  


explain php variable length argument function.

1 Answers  


what are the differents between 'action' and 'target' in form tag?

3 Answers  


What are soundex() and metaphone() functions in php?

1 Answers  


What is the use of return in php?

1 Answers  


Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?

1 Answers  


What are the differences between PHP3 and PHP4 and PHP5? what is the current stable version of PHP?

1 Answers  


Can anybody plz tell me if there any recruitment on php plz mail to vasudev.adepu@gmail.com.i had completed M.SC(MATHS) in 2007 . trying to get a job on php. i have good knowledge on PHP/MYSQL

1 Answers  


What is the use of hooks?

1 Answers  


Categories