Custom Search

Thursday, February 28, 2013

PHP AND MYSQL


1. What are the differences between GET And POST methods in form submitting, givethe case where we can use get and we can use post methods?

On the server side, the main difference between GET and POST is where thesubmitted is stored. The $_GET array stores data submitted by the GET method.The $_POST array stores data submitted by the POST method.On the browser side, the difference is that data submitted by the GET method willbe displayed in the browser's address field. Data submitted by the POST methodwill not be displayed anywhere on the browser.GET method is mostly used for submitting a small amount and less sensitive data.POST method is mostly used for submitting a large amount or sensitive data.

2. Who is the father of php and explain the changes in php versions?

Answer:Rasmus Lerdorf for version changes go to Marco Tabini is the founder and publisher of php|architect.

3. How can we submit from without a submit button?

Answer:We can use a simple JavaScript code linked to an event trigger of any form field.In the JavaScript code, we can call the document.form.submit() function to submitthe form.

4. How many ways we can retrieve the date in result set of mysql Using php?

Answer:As individual objects so single record or as a set or arrays.

 5. What is the difference between mysql_fetch_object and mysql_fetch_array?

Answer:MySQL fetch object will collect first single matching record wheremysql_fetch_array will collect all matching records from the table in an array.

 6. What is the difference between $message and $$message?

Answer:They are both variables. But $message is a variable with a fixed name. $$message isa variable who's name is stored in $message. For example, if $message contains"var", $$message is the same as $var.


 7. How can we extract string 'abc.com ' from a string'http://info@a...' using regular _expression of php?

Answer:We can use the preg_match() function with "/.*@(.*)$/" asthe regular expression pattern. For example:preg_match("/.*@(.*)$/","http://info@abc.com",$data);echo $data[1];

8. How can we create a database using php and mysql?

Answer:PHP: mysql_create_db()Mysql: create database;

9. What are the differences between require and include, include_once?

Answer:File will not be included more than once. If we want to include a file once only andfurther calling of the file will be ignored then we have to use the PHP functioninclude_once(). This will prevent problems with function redefinitions, variablevalue reassignments, etc.

10. Can we use include ("abc.php") two times in a php page "makeit.php"?

Answer:Yes we can include..

 11. What are the different tables present in mysql, which type of table is generated whenwe are creating a table in the followingsyntax: create table employee(eno int(2),ename varchar(10)) ?

Answer:Total 5 types of tables we can create1. MyISAM2. Heap3. Merge4. InnoDB5. ISAM6. BDBMyISAM is the default storage engine as of MySQL 3.23.

12. Functions in IMAP, POP3 AND LDAP?

Answer:Please visit:http://fi2.php.net/imaphttp://uk2.php.net/ldap

13. How can I execute a php script using command line?

Just run the PHP CLI (Command Line Interface) program and provide the PHPscript file name as the command line argument. For example, "php myScript.php",assuming "php" is the command to invoke the CLI program.Be aware that if your PHP script was written for the Web CGI interface, it may notexecute properly in command line environment.


14. What are the reasons for selecting lamp (Linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?

Answer:All of those are open source resource. Security of linux is very very more thanwindows. Apache is a better server that IIS both in functionality and security.Mysql is world most popular open source database. Php is more faster that asp orany other scripting language.

15.  How can we encrypt and decrypt a data present in a mysql table using mysql?
Answer:AES_ENCRYPT () and AES_DECRYPT ()



16. What are the different types of errors in php?

Answer:Three are three types of errors:
1.Notices: These are trivial, non-critical errors that PHP encounters whileexecuting 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 behaviour.
2.Warnings: These are more serious errors - for example, attempting to include() afile which does not exist. By default, these errors are displayed to the user, but theydo not result in script termination.
3.Fatal errors: These are critical errors - for example, instantiating an object of anon-existent class, or calling a non-existent function. These errors cause theimmediate termination of the script, and PHP's default behaviour is to display themto the user when they take place.

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

Answer:strstr() returns part of a given string from the first occurrence of a given substringto the end of the string. For example: strstr("user@example.com","@") will return"@example.com".stristr() is idential to strstr() except that it is case insensitive.
18. What is the functionality of the function htmlentities?

Answer:htmlentities -- Convert all applicable characters to HTML entitiesThis function is identical tohtmlspecialchars()in all ways, except withhtmlentities(), all characters which have HTML character entity equivalents aretranslated into these entities.

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

Answer:$second = date(“s”);
20. How can we convert the time zones using php?

Answer:

21. What is meant by urlencode and urldocode?

Answer:urlencode() returns the URL encoded version of the given string. URL codingconverts special characters into % signs followed by two hex digits. For example:urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe tobe used as part of URLs.urldecode() returns the URL decoded version of the given string.

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

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

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

Answer:We can use the session_register ($ur_session_var) function.
24. How can we get the properties (size, type, width, height) of an image using phpimage functions?

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

25. How can we get the browser properties using php?

Answer:

26. What is the maximum size of a file that can be uploaded using php and how can wechange this?
Answer:You can change maximum size of a file set upload_max_filesize variable in php.inifile

27. How can we increase the execution time of a php script?

Answer:Set max_execution_time variable in php.ini file to your desired time in second.

28. How many ways can we get the value of current session id?

Answer:session_id() returns the session id for the current session.
43. How can we destroy the session, how can we unset the variable of a session?
Answer:session_unregister() unregisters a global variable from the current session.session_unset() frees all session variables.

29. How can we destroy the cookie?

Answer::Set the cookie in past.

30. How many ways we can pass the variable through the navigation between the pages?

Answer:At least 3 ways:a) Register the variable into the sessionb) Pass the variable as a cookiec) Pass the variable as part of the URL

31. What is the difference between ereg_replace() and eregi_replace()?

Answer:eregi_replace() function is identical to ereg_replace() except that this ignores casedistinction when matching alphabetic characters.

32. What are the different functions in sorting an array?

Answer:Sorting functions in PHP:asort()arsort()ksort()krsort()uksort()sort()natsort()rsort()

33. How can we know the count/number of elements of an array?

Answer:2 ways:a) sizeof($urarray) This function is an alias of count()b) count($urarray)Interestingly if u just pass a simple var instead of a an array it will return 1.

34. What is the php predefined variable that tells the What types of images that phpsupports?

Answer:
$_SERVER['HTTP_ACCEPT']


35. List out some tools through which we can draw E-R diagrams for mysql.

Answer:Dbdesigner, conceptdraw etc.


36. List out the predefined classes in php?

Answer:DirectorystdClass__PHP_Incomplete_Class
exceptionphp_user_filter


37. What are the difference between abstract class and interface?

Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are themethods, which are declare in its class but not define. The definition of thosemethods must be in its extending class.Interface: Interfaces are one type of class where all the methods are abstract. Thatmeans all the methods only declared but not defined. All the methods must be defineby its implemented class.

38. How can we repair a mysql table?

Answer:The syntex for repairing a mysql table isREPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]This command will repair the table specifiedif the quick is given the mysql will do a repair of only the index tree if the extendedis given it will create index row by row


39. What is the maximum length of a table name, database name, and fieldname inmysql?

Answer:Database name- 64Table name -64Fieldname-64

40. How many values can the SET function of mysql takes?

Answer:Mysql set can take zero or more values but at the maximum it can take 64 values

No comments:

Post a Comment