Sunday, September 23, 2007

phpquestions and answers

18. What are the different types of errors in PHP?

A: Basically 3 types of errors

i. Notices - These are non critical error

ii. Warning – These are more serious error

iii. Fatal error – These are more critical error

19. What is the functionality of the function strstr and stristr?

A: strstr – It returns part of the string from first occurrence of the string. It is case sensitive search.

stristr – It is also returns part of the string from first occurrence of the string. But it is case insensitive search.

20. What is the functionality of the function htmlentities?

A: It is used to convert all special characters to HTML entities

21. How can we get second of the current time using date function?

A: echo date("s");

22. What is meant by urlencode and urldocode?

A: urlencode()

URL coding converts special characters into % signs followed by two hex digits

URL encoded strings are safe to be used as part of URL

urldecode()

It returns the URL decoded version of the given string.

23. What is the difference between the functions unlink and unset?

A: unlink – Used to delete file

Unset – Used to destroy variable

24. How can we register the variables into a session?

A: session_register($session_varname);

25. How can we get the properties (size, type, width, height) of an image using PHP image functions?

A: Image Size: getimagesize

Image type: image_type_to_extension

Image width: imagesx

Image height: imagesy



26. How can we get the browser properties using PHP?

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

A: The maximum size of an uploaded file is based on execution time.

Default upload size is 2 mb.



We can change In php.ini file: upload_max_filesize integer

No comments: