adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the current stable version of php?

1124


What sized websites have you worked on in the past?

1086


hello all, I need some sample placement papers in lion bridge.. can anyone help me?

2177


Explain me is it possible to destroy a cookie?

1029


Name and explain five of the PHP error constants?

1035


What is the difference between htmlentities() and htmlspecialchars()?

1091


What is trait in php?

1065


How to create a web form?

1111


What does $_files means?

1162


Which variable declarations within a class is invalid in php?

1048


What is the current stable version of php? What advance thing in php7?

1095


Write a program using while loop?

1118


How can we extract string "pcds.co.in" from a string "https://info@pcds.co.in" using regular expression of php? More on reg can you explain

1078


What is difference between static and final in php?

1109


How to calculate the difference between two dates using php?

1144