/    Sign up×
Community /Pin to ProfileBookmark

Weird issue with evaluating numbers

I have tried this code on two separate shared hosts and I am having the same problem.

[CODE]<?

if (06 < 07) echo ‘true’; else echo ‘false’;

if (07 < 08) echo ‘true’; else echo ‘false’;

?>
[/CODE]

The first line returns true but the second returns false. How does that make sense? This only happens if the second value is 08 or 09.

Update – Solved it by putting quotes around the numbers, but still confused on why it does not work properly without them?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 14.2010 — When not quoted as a string, an integer with a leading 0 is treated as an octal number. Any invalid digit (e.g. 8 or 9) will be ignored, as will any subsequent digits. So 08 (not quoted) becomes an integer 0.
Copy linkTweet thisAlerts:
@yahooman123authorAug 14.2010 — ah thanks for the explanation
×

Success!

Help @yahooman123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...