Home » PHP

PHP chr() function with example

PHP chr() function: Here, we are going to learn about the chr() function with example in PHP.
Submitted by IncludeHelp, on February 03, 2019

PHP chr() function

chr() function is used to get the character from a given ASCII code. ASCII value can be in decimal format, octal format by following 0 (zero), and hexadecimal format by following 0x.

Syntax:

    chr(ASCII_value);

Function accepts ASCII value in number and returns corresponding character.

Examples:

    Input: 65
    Output: 'A'

    Input: 0x41
    Output: 'A'

PHP code:

<?php
    echo (chr(65)."\n"); //ASCII value of 'A' in decimal
    echo (chr(0101)."\n"); //ASCII value of 'A' in octal
    echo (chr(0x41)."\n"); //ASCII value of 'A' in hex
?>

Output

A
A
A




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.