Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update intval doc with explicit binary numeral notation #2686

Merged
merged 1 commit into from
Aug 27, 2023

Conversation

jawira
Copy link
Contributor

@jawira jawira commented Aug 15, 2023

In intval function, the base parameter allows to set the desired base to convert a string to int.

The base "0" works as "automatic base", the base will be detected:

echo intval('101', 0);   // 101
echo intval('0x101', 0); // 257
echo intval('0X101', 0); // 257
echo intval('0b101', 0); // 5
echo intval('0B101', 0); // 5
echo intval('0101', 0);  // 65

I updated the documentation to include binary 0b and 0B prefixes.

I would have liked to do the same for octal numeral notation, but 0o and 0O seems to not be implemented yet, only 0 works.

@TimWolla TimWolla merged commit 18c4f78 into php:master Aug 27, 2023
2 checks passed
@TimWolla
Copy link
Member

Thanks!

@jawira jawira deleted the intval_binary branch August 27, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants