Pseudo Types

Estudies4you
Pseudo Types in PHP
Pseudo Types
  • Pseudo types are data types used in PHP documentations to explain certain features.
  • They do not really exist.
  • In PHP programming syntax, you would be seeing pseudo types as follows

Pseudo Types in PHP

Number
  • Number is a pseudo type, which means that a parameter is either an integer or a float.
  • To use octal notation, precede the number with 0
  • To use hexadecimal notation, precede the number with Ox
  • To use binary notation, precede the number with Ob
Note: Binary integer literals are only available since PHP 5.4.0.
Example:
<?php
$a = 1234; // decimal number
$a = -123; // a negative number
$a = 0123; // octal number (equivalent to 83 decimal)
$a = Ox1A; // hexadecimal number (equivalent to 26 decimal)
?>

Mixed
  • A Mixed indicates that a parameter may accept multiple (but not necessarily all) types.
  • Mixed simply means an integer or a float or a string or a bool, etc.

Void
  • A void as a return type means that the return value is useless. void in a parameter list means that the function doesn't accept any parameters.
Example:
<?php
$txt="Hello world!";
echo $txt;
$my_name = 'Raju';
?>

Callback
  • call_user_func() and usort() are predefined functions. These two functions and some other predefined functions can take the name of a function as a parameter. Any function whose name goes as a parameter to these functions is called a callback function. I will use only the call_user_func() function to illustrate the behavior of a callback function.


To Top