String Functions

PHP ord() Function

Topic: PHP String ReferencePrev|Next

Description

The ord() function convert the first byte of a string to a value between 0 and 255 (i.e. ASCII value).

The following table summarizes the technical details of this function.

Return Value: Returns an integer between 0 and 255.
Version: PHP 4+

Syntax

The basic syntax of the ord() function is given with:

ord(string);

The following example shows the ord() function in action.

<?php
echo ord("\n");      // Outputs: 10
echo ord("\nHello"); // Outputs: 10
echo ord("#main");   // Outputs: 35
?>

Parameters

The ord() function accepts the following parameters.

Parameter Description
string Required. Specifies the input string.
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties