w3resource

PHP: ord() function

PHP: Convert the first byte of a string to a value between 0 and 255

The ord() function is used to get the ASCII value of the first character of a string.

Version:

(PHP 4 and above)

Syntax:

ord(string1)

Parameter:

Name Description Required /
Optional
Type
string1 The input string. Required String

Return value

The ASCII value as an integer.

Value Type: Integer.

Pictorial Presentation

php-string-ord()

Example of php ord() function

<?php
$str1='w3resource.com';
echo ord($str1);
?>

Output:

119

View the example in the browser

See also

PHP Function Reference

Previous: number_format
Next: parse_str



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/ord.php