Tamil cinema News,Videos,Songs,Photos and Tailers :: Tamil Cinema Bazaar

Pages

Infolinks In Text Ads

Saturday 17 September 2011

Php Interview Questions And Answers - 2

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

 Three are three types of errors: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. By default,
such errors are not displayed to the user at all although, as you will
see, you can change this default behavior.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.

Php Interview Questions And Answers
      
27. What is the functionality of the function strstr and stristr?


strstr Returns part of string from the first occurrence of needle(sub string that we finding out ) to the end
of string.
$email= 'sonialouder@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
here @ is the needle
stristr is case-insensitive means able not able to diffrenciate between a and A

Php Interview Questions And Answers 
       
28. What are the differences between PHP 3 and PHP 4 and PHP 5?

There are lot of difference among these three version of php
1>Php3 is oldest version after that php4 came and current version is php5 (php5.3) where php6 have to come
2>Difference mean oldest version have less functionality as compare to new one like php5 have all OOPs concept now where as

php3 was pure procedural language constructive like C
In PHP5 1. Implementation of exceptions and exception handling
2. Type hinting which allows you to force the type of a specific argument
3. Overloading of methods through the __call function
4. Full constructors and destructors etc through a __constuctor and __destructor function
5. __autoload function for dynamically including certain include files depending on the class you are trying to create.
6 Finality : can now use the final keyword to indicate that a method cannot be overridden by a child. You can also declare an entire class as final which prevents it from having any children at all.
7 Interfaces & Abstract Classes
8 Passed by Reference :
9 An __clone method if you really want to duplicate an object

Php Interview Questions And Answers 
       
29. How can we convert asp pages to PHP pages?

There are lots of tools available for asp to PHP conversion. you can
search Google for that. the best one is available athttp://asp2php.naken.cc./

Php Interview Questions And Answers 
       
30. What is the functionality of the function htmlentities?


Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except
with htmlentities(), all characters which have HTML character entity
equivalents are translated into these entities.


Php Interview Questions And Answers 
       
31. How can we get second of the current time using date function?

$second = date("s");

Php Interview Questions And Answers       

32. How can we convert the time zones using PHP?


By using date_default_timezone_get and
date_default_timezone_set function on PHP 5.1.0

<?php
// Discover what 8am in Tokyo relates to on the East Coast of the US   

// Set the default timezone to Tokyo time:
date_default_timezone_set('Asia/Tokyo');   

// Now generate the timestamp for that particular timezone, on Jan 1st, 2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);   

// Now set the timezone back to US/Eastern
date_default_timezone_set('US/Eastern');   

// Output the date in a standard format (RFC1123), this will print:
// Fri, 31 Dec 1999 18:00:00 EST
echo '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>

Php Interview Questions And Answers 
       
33. What is meant by urlencode and urldocode?

URLencode returns a string in which all non-alphanumeric characters
except -_. have been replaced with a percent (%)
sign followed by two hex digits and spaces encoded as plus (+)
signs. It is encoded the same way that the posted data from a WWW form
is encoded, that is the same way as in
application/x-www-form-urlencoded media type.

urldecode decodes any %##
encoding in the given string.


Php Interview Questions And Answers 
       
34. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.
unset() makes a variable undefined.


Php Interview Questions And Answers 
       
35. How can we register the variables into a session?

$_SESSION['name'] = "sonia";


Php Interview Questions And Answers 
       
36. How can we get the properties (size, type, width, height) of an image using PHP image functions?


To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function t


Php Interview Questions And Answers 
       
37. How can we get the browser properties using PHP?

By using
$_SERVER['HTTP_USER_AGENT']
variable.


Php Interview Questions And Answers 
       
38. 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. and we can change the following
setup at php.iniupload_max_filesize = 2M


Php Interview Questions And Answers 
       
39. How can we increase the execution time of a PHP script?

By changing the following setup at php.inimax_execution_time = 30
; Maximum execution time of each script, in seconds


Php Interview Questions And Answers 
       
40. How can we take a backup of a MySQL table and how can we restore it ?


To backup: BACKUP TABLE tbl_name[,tbl_name…] TO
'/path/to/backup/directory'
RESTORE TABLE tbl_name[,tbl_name…] FROM '/path/to/backup/directory'mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or
for transferring the data to another SQL server (not necessarily a MySQL
server). The dump will contain SQL statements to create the table and/or
populate the table.
-t, –no-create-info
Don't write table creation information (the CREATE TABLE statement).
-d, –no-data
Don't write any row information for the table. This is very useful if
you just want to get a dump of the structure for a table!


Php Interview Questions And Answers 
       
41. How can we optimize or increase the speed of a MySQL select query?
 
    * first of all instead of using select * from table1, use select
      column1, column2, column3.. from table1
    * Look for the opportunity to introduce index in the table you are
      querying.
    * use limit keyword if you are looking for any specific number of
      rows from the result set.

Php Interview Questions And Answers 
       
42. How many ways can we get the value of current session id?

session_id() returns the session id for the current session.


Php Interview Questions And Answers 
       
43. How can we destroy the session, how can we unset the variable of a session?

session_unregister — Unregister a global variable from the current
session
session_unset — Free all session variables


Php Interview Questions And Answers 
       
44. How can we set and destroy the cookie n php?

By using setcookie(name, value, expire, path, domain); function we can set the cookie in php ;
Set the cookies in past for destroy. like
setcookie("user", "sonia", time()+3600); for set the cookie
setcookie("user", "", time()-3600); for destroy or delete the cookies;


Php Interview Questions And Answers 
       
45. How many ways we can pass the variable through the navigation between the pages?
 
    * GET/QueryString
    * POST


Php Interview Questions And Answers 
       
46. What is the difference between ereg_replace() and eregi_replace()?

eregi_replace() function is identical to ereg_replace() except that
this ignores case distinction when matching alphabetic
characters.eregi_replace() function is identical to ereg_replace()
except that this ignores case distinction when matching alphabetic
characters.


Php Interview Questions And Answers 
       
47. What are the different functions in sorting an array?

Sort(), arsort(),
asort(), ksort(),
natsort(), natcasesort(),
rsort(), usort(),
array_multisort(), and
uksort().


Php Interview Questions And Answers 
       
48. How can we know the count/number of elements of an array?

2 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)


Php Interview Questions And Answers 
       
49. What is session_set_save_handler in PHP?

session_set_save_handler() sets the user-level session storage functions which are used for storing and
retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database.


Php Interview Questions And Answers 
       
50. How can I know that a variable is a number or not using a JavaScript?

bool is_numeric ( mixed var)
Returns TRUE if var is a number or a numeric string, FALSE otherwise.or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.

Php Interview Questions And Answers 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive