GoLang ord

is this article helpful? yes | no
GoLang replacement for PHP's ord [Golang Play | edit | history]
ch := rune(97)
n := int('a')
fmt.Printf("char: %c\n", ch)
fmt.Printf("code: %d\n", n)

PHP ord

PHP original manual for ord [ show | php.net ]

ord

(PHP 4, PHP 5, PHP 7)

ordReturn ASCII value of character

Description

int ord ( string $string )

Returns the ASCII value of the first character of string.

This function complements chr().

Parameters

string

A character.

Return Values

Returns the ASCII value as an integer.

Examples

Example #1 ord() example

<?php
$str 
"\n";
if (
ord($str) == 10) {
    echo 
"The first character of \$str is a line feed.\n";
}
?>

See Also