To obtain the ASCII value of a character in PHP, you would use the ord()
function.
Let's go through each option to understand why it is correct or incorrect:
Option A) chr()
- This option is incorrect because the chr()
function is used to convert an ASCII value to its corresponding character.
Option B) asc()
- This option is incorrect because there is no built-in asc()
function in PHP. It is not a valid function for obtaining the ASCII value of a character.
Option C) ord()
- This option is correct because the ord()
function in PHP is used to obtain the ASCII value of a character.
Option D) val()
- This option is incorrect because the val()
function in PHP is used to obtain the numerical value of a variable, not the ASCII value of a character.
The correct answer is option C) ord()
. This option is correct because the ord()
function is specifically designed to obtain the ASCII value of a character in PHP.