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



PHP: Tips of the Day

PHP: PHPDoc type hinting for array of objects?

Use:

/* @var $objs Test[] */
foreach ($objs as $obj) {
    // Typehinting will occur after typing $obj->
}

when typehinting inline variables, and

class A {
    /** @var Test[] */
    private $items;
}

Ref : https://bit.ly/31a2QJN