- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In php, is 123==0123?
The answer is No. This is because 0123 means 123 with base 8 (an octal number) and its equivalent in decimal is 83.
Prefixing a number with 0 indicates that it is an octal (base 8) number. This is similar to the fact that 0x indicates hex (base 16) numbers.
Consider the below lines of code −
Example
var_dump(123); var_dump(0123);
Output
This will produce the following output −
int 123 int 83
This is due to the fact that 0123 is an octal notation (notice the 0 at the beginning), whereas 123 is a decimal number.
Now consider the below code −
Example
var_dump(79); var_dump(079);
Output
This will produce the following output −
int 79 int 7
Advertisements