Character set of PHP language

Notes:

Character set of PHP

First step in learning any language is; knowing its character set.

How do we have learnt English language?

Digits: 0,1,2,3,4,5,6,7,8,9
Alphabets: A - Z & a – z
Special Characters:, , ., ;, : ~,!,@,#,$,%,^,&,*,(,),-,_,+,= etc.

Character set: Set of characters used in the language for forming words, sentences, paragraphs etc.

As PHP is also a language, it also has set of characters used in forming tokens, instructions, functions, etc.

Digits: 0,1,2,3,4,5,6,7,8,9
Alphabets: A - Z & a – z
Special Characters:, , ., ;, : ~,!,@,#,$,%,^,&,*,(,),-,_,+,= etc.
Escape sequence characters: \n, \t ,\v,\a,\b,\\,\”,\’ etc.

PHP uses ASCII character set to define all its language constructs

ASCII (7bit - 128): American Standards Code for Information Interchange
For every character there is a unique number in ASCII character set

Ex:

<?php
echo "A";
echo "<br/>";

echo chr(65); // A // returns a character of the given ascii value
echo "<br/>";
echo chr(97); // a
echo "<br/>";
echo ord("a"); // 97 // returns an ascii value of the first character of a given string
echo "<br/>";
echo ord("A"); // 65
?>

Unicode (32 bit – 4294967296): Universal Coded Character set
It is designed to represent almost all characters form all most all languages present in the world.
We can also display characters from Unicode character set by their code

Ex:

<?php
echo "A"; // English A
echo "<br/>";
echo "अ"; // Hindi A
echo "<br/>";
?>

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a