w3resource

PHP: ord() function

Description

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



Inviting useful, relevant, well-written and unique guest posts