pTutorial

New way to learn PHP Example

How To Print ASCII value in PHP

chr function example

Display the ASCII value from Decimal number

<?php

    $ascii1 = chr(65);
    echo "ASCII value of  65 is : $ascii1
"; $ascii2 = chr(97); echo "ASCII value of 97 is : $ascii2
"; $ascii3 = chr(61); echo "ASCII value of 61 is : $ascii3
"; $ascii4 = chr(42); echo "ASCII value of 42 is : $ascii4
"; ?>

Explanation

Print the character of ASCII value using the chr() function,The chr() function always returns a character

In this example first create a variable and assign chr (number).

Number is what, number is nothing just an integer that you want to find the ASCII value.

ord function example

Display the ASCII value of Decimal number

<?php

   $ascii1 = ord('A');
    echo "ASCII value of  A is : $ascii1
"; $ascii2 = ord('z'); echo "ASCII value of z is : $ascii2
"; $ascii3 = ord('+'); echo "ASCII value of + is : $ascii3
"; $ascii4 = ord('#'); echo "ASCII value of # is : $ascii4
"; ?>

Explanation

Print the ASCII value using the ord() function, The ord() function always returns a ASCII value of a character

In this example first create a variable and assign ord (character).

Character is what, character is not only A to Z all the special symbol and number also.

If you want to learn more about function chr () and ord () then click on this


QUOTES OF THE DAY

The basis of all progress is self-reliance

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER