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



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

Answer / Om Prakash Meena

In PHP, numbers and strings are treated differently. The string "0123" is interpreted as an octal (base 8) number, which has a value of 67. To assign the value 0123 as an integer or decimal number, you can remove the leading zeros:n`n$num = 0123; // Integern$decimalNum = 0.123; // Decimaln`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What are the advantages and disadvantages of cascade style sheets?

1 Answers  


What are the advantages of triggers in php?

1 Answers  


When is a conditional statement ended with endif?

1 Answers  


Tell me how is it possible to remove escape characters from a string?

1 Answers  


How to concatenate two strings in php?

1 Answers  


Does php need a closing tag?

1 Answers  


Explain a resource?

1 Answers  


What is better .net or php?

1 Answers  


Which php function will attach one file to another?

1 Answers  


Explain me what is the w3c?

1 Answers  


What is html used for?

1 Answers  


What is die in php?

1 Answers  


Categories