How do you define a constant in php?

by define() directive,
like define (“MYCONSTANT”, 500);

THE DIFFERENT TYPES OF ERRORS IN PHP?

1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined
2. Warnings: These are more serious errors – for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These are critical errors – for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.
Internally, these variations are represented by twelve different error types

What’s the special meaning of __sleep and __wakeup?

__sleep returns the array of all the variables than need to be saved,
while __wakeup retrieves them.

What is the difference between $age and $$age

They are both variables. But $age is a variable with a fixed name. $$age is a variable who’s name is stored in $age. For example, if $age contains “var”, $$age is the same as $var.

$test = ‘abcd';
is equivalent to
$holder = ‘test';
 $$holder = ‘abcd';

How many values can the SET function of MySQL take?

MySQL set can take zero or more values but at the maximum it can
take 64 values

What is the maximum size of a file that can be uploaded using PHP and how can we change this?

By default the maximum size is 2MB.
 can change the size
 setup at php.ini
upload_max_filesize = 12M

How can we get the browser properties using PHP?

$_SERVER['HTTP_USER_AGENT'];

How can we encrypt the username and password using PHP?

The functions in this section perform encryption and decryption

encryption decryption
AES_ENCRYT() AES_DECRYPT()
ENCODE() DECODE()
DES_ENCRYPT() DES_DECRYPT()
ENCRYPT() Not available
MD5() Not available
OLD_PASSWORD() Not available
PASSWORD() Not available
SHA() or SHA1() Not available
Not available UNCOMPRESSED_LENGTH()

count the elements of an array?

sizeof($array) – This function is an alias of count()

 count($urarray) – This function returns the number of elements in an array.

sorting an array?

arsort()
sort()
natsort()