Top PHP Interview Questions and Answers

1. what's PHP?
Ans:
PHP (Hyper text Pre Processor) may be a scripting language unremarkably used for internet applications. PHP will besimply embedded in hypertext markup language. PHP usually runs on an online server. it's out there for free of charge and might be used across a spread of servers, operational systems and platforms.

2. What ar the variations between GET and POST strategies in kind submitting, offer the case wherever will|we will|we are able to} use get and that we can use post methods?
Ans:
On the server facet, the most distinction between GET and POST is wherever the submitted is keep. The $_GET array stores information submitted by the GET methodology. The $_POST array stores information submitted by the POST methodology. 

On the browser facet, the distinction is that information submitted by the GET methodology are going to bedisplayed within the browser's address field. information submitted by the POST methodology won't be displayed anyplace on the browser. 

GET methodology is generally used for submitting atiny low quantity and fewer sensitive information. POST methodology is generally used for submitting an oversized quantity or sensitive information.

3. World Health Organization is that the father of php and make a case for the changes in php versions?
Ans:
Rasmus Lerdorf for version changes head to http://php.net/ Marco Tabini is that the founder and publisher of php|architect.

4. however will we have a tendency to submit from while not a submit button?
Ans:
We can use a straightforward JavaScript code coupled to an occurrence trigger of any kind field. within theJavaScript code, we are able to decision the document.form.submit() operate to submit the shape.

5. what number ways that we are able to retrieve the date in result set of mysql mistreatment php?
Ans:
As individual objects thus single record or as a group or arrays.

6. what's the distinction between $message and $message?
Ans:
They are each variables. however $message may be a variable with a hard and fast name. $message may be avariable who's name is keep in $message. as an example, if $message contains "var", $message is that the same as $var.

7. What ar the variations between need and embrace, include_once?
Ans:
File won't be enclosed over once. If we would like to incorporate a file once solely and more line of work of the file are going to be neglected then we've got to use the PHP operate include_once(). this may forestall issues with operate redefinitions, variable price reassignments, etc.

8. What ar the various tables gift in mysql?
Ans:
Total five sorts of tables we are able to produce 

1. MyISAM 

2. Heap 

3. Merge 

4. InnoDB 

5. ISAM 

6. BDB 

MyISAM is that the default storage engine as of MySQL three.23.

9. however am i able to execute a php script mistreatment command line?
Ans:
Just run the PHP CLI (Command Line Interface) program and supply the PHP script file name because the statementargument. as an example, "php myScript.php", forward "php" is that the command to invoke the CLI program. 

Be aware that if your PHP script was written for the net CGI interface, it should not execute properly in statementatmosphere.

10. what's meant by nl2br()?
Ans:
Nl2br Inserts hypertext markup language line breaks before all newlines in a very string string nl2br (string); For example: echo nl2br("god bless you")

will output "god bless you" to your browser.

11. What ar the present versions of apache, php, and mysql?
Ans:
PHP: php 5.3 
MySQL: MySQL five.5 
Apache: Apache a pair of.2

12. What ar the explanations for choosing lamp (Linux, apache, mysql, php) rather than combination of differentsoftware package programs, servers and operational systems?
Ans:
All of these ar open supply resource. Security of UNIX operating system terribly|is extremely|is incredibly} very overwindows. Apache may be a higher server that IIS each in practicality and security. Mysql is world preferred open supply information. PHP is a lot of quicker that asp or the other scripting language.

13. however will we have a tendency to inscribe and decode an information gift in a very mysql table mistreatment mysql?
Ans:
AES_ENCRYPT () and AES_DECRYPT ()

14. however will we have a tendency to inscribe the username and secret mistreatment php?
Ans:
You can inscribe a secret with the subsequent Mysql>SET PASSWORD=PASSWORD("Password"); we are able toinscribe information mistreatment base64_encode($string) and might rewrite mistreatmentbase64_decode($string);

15. What ar the various sorts of errors in php?
Ans:
E_ERROR: A fatal error that causes script termination 
E_WARNING: Run-time warning that doesn't cause script termination 
E_PARSE: Compile time break down error. 
E_NOTICE: Run time notice caused owing to error in code 
E_CORE_ERROR: Fatal errors that occur throughout PHP's initial startup (installation) 
E_CORE_WARNING: Warnings that occur throughout PHP's initial startup 
E_COMPILE_ERROR: Fatal compile-time errors indication drawback with script. 
E_USER_ERROR: User-generated error message. 
E_USER_WARNING: User-generated warning message. 
E_USER_NOTICE: User-generated notice message. 
E_STRICT: Run-time notices. 
E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error 
E_ALL: Catches all errors and warnings

16. what's the practicality of the operate htmlentities?
Ans:
Answer: htmlentities Convert all applicable characters to hypertext markup language entities This operate is clone ofhtmlspecialchars() all told ways that, except with htmlentities(), all characters that have hypertext markup languagecharacter entity equivalents ar translated into these entities.

17. what's meant by urlencode and urldocode?
Ans:
Urlencode() returns the uniform resource locator encoded version of the given string. uniform resource locatorsecret writing converts special characters under consideration signs followed by 2 hex digits. For example: urlencode("10.00%") can come back "10%2E00%25?. uniform resource locator encoded strings ar safe to be used as a part of URLs. 
urldecode() returns the uniform resource locator decoded version of the given string.

18. what's the distinction between the functions unlink and unset?
Ans:
Unlink() deletes the given file from the classification system. 
unset() makes a variable indefinable.

19. however will we have a tendency to register the variables into a session?
Ans:
We can use the session_register ($ur_session_var) operate.

20. however will we have a tendency to get the properties (size, type, width, height) of a picture mistreatment php image functions?
Ans:
To know the Image kind use exif_imagetype () operate 
To know the Image size use getimagesize () operate 
To know the image breadth use imagesx () operate 
To know the image height use imagesy() operate

21. what's the most size of a file {that will|which will|that may} be uploaded mistreatment php and the way can we alter this?
Ans:
You can modification most size of a file set upload_max_filesize variable in php.ini file.

22. however will we have a tendency to increase the execution time of a php script?
Ans:
Set max_execution_time variable in php.ini file to your required time in second.

23. however will we have a tendency to take a backup of a mysql table and the way will we have a tendency torestore it.?
Ans:
Create a full backup of your database: shell> mysqldump tab=/path/to/some/diropt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir the total computer file is simply a group of SQL statements, thus restoring it's terriblyeasy: 

shell> mysql "."Executed"; 
mysql_close($link2);

24. what number ways that will we have a tendency to get the worth of current session id?
Ans:
session_id() operate returns the session id for the present session.

25. however will we have a tendency to destroy the session, however will we have a tendency to unset the variable of a session?
Ans:
session_destroy
session_unset

26. however will we have a tendency to destroy the cookie?
Ans:
Set same the cookie in past

27. what's the distinction between ereg_replace() and eregi_replace()?
Ans:
eregi_replace() operate is clone of ereg_replace() except that this ignores case distinction once matching alphabetic characters.eregi_replace() operate is clone of ereg_replace() except that this ignores case distinction once matching alphabetic characters.

28. however will we all know the count/number of parts of AN array?
Ans:
2 ways 
a) sizeof($urarray) This operate is AN alias of count() 
b) count($urarray)
interestingly if u simply pass a straightforward volt-ampere rather than a AN array it'll come back one.

29. what's the most length of a table name, information name, and fieldname in mysql?
Ans:
Database name- sixty four 
Table name -64 Fieldname-64

30. what number values will the SET operate of mysql takes?
Ans:
Mysql set will take zero or a lot of values however at the most it will take sixty four values

31.What is most size of a information in mysql?
Ans:
If the package or filesystem places a limit on the amount of files in a very directory, MySQL is sure by that constraint. 
The potency of the package in handling giant numbers of files in a very directory will place a sensible limit on the amount of tables in a very information. If the time needed to open a go in the directory will increase considerablybecause the variety of files will increase, information performance will be adversely affected. 
The amount of obtainable disc space limits the amount of tables. 
MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage engine in MySQL three.23, the mosttable size was enhanced to 65536 terabytes (2567 â€" one bytes). With this larger allowed table size, the mosteffective table size for MySQL databases is sometimes determined by package constraints on file sizes, not by MySQL internal limits. 
The InnoDB storage engine maintains InnoDB tables among a tablespace that may be created from many files. this permits a table to exceed the most individual file size. The tablespace will embrace raw disk partitions, that permitsextraordinarily giant tables. the most tablespace size is 64TB. 
The following table lists some samples of package file-size limits. this is often solely a rough guide and isn't meant to be definitive. For the foremost up-to-date info, take care to envision the documentation specific to your package. 
Operating System File-size Limit 
Linux 2.2-Intel 32-bit 2GB (LFS: 4GB) 
Linux 2.4+ (using ext3 filesystem) 4TB 
Solaris 9/10 16TB 
NetWare w/NSS filesystem 8TB 
Win32 w/ FAT/FAT32 2GB/4GB 
Win32 w/ NTFS 2TB (possibly larger) 
MacOS X w/ HFS+ 2TB

32. what's meant by MIME?
Ans:
Multipurpose web Mail Extensions.
WWW ability to recognise and handle files of various sorts is essentially addicted to the employment of the MIME (Multipurpose web Mail Extensions) normal. the quality provides for a system of registration of file sorts with infoconcerning the applications required to method them. This info is incorporated into internet server and browser software package, and allows the automated recognition and show of registered file sorts.

33. what's meant by PEAR in php?
Ans:
PEAR is brief for "PHP Extension and Application Repository" and is pronounced similar to the fruit. the aim of PEAR is to provide: 
A structured library of open-sourced code for PHP users 
A system for code distribution and package maintenance 
A standard vogue for code written in PHP 
The PHP Foundation categories (PFC), 
The PHP Extension Community Library (PECL), 
A web site, mailing lists and transfer mirrors to support the PHP/PEAR community 
PEAR may be a community-driven project with the PEAR cluster because the organization. The project has been supported by Stig S. Bakken in 1999 and quite an heap of individuals have joined the project since then. 

http://pear.php.net/manual/en/about.pear.php

34. What ar the variations between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
Ans:
Mysql_fetch_array Fetch a result row as AN associative array, a numeric array, or both. 
mysql_fetch_object ( resource result ) 
Returns AN object with properties that correspond to the fetched row and moves the interior information pointer ahead. Returns AN object with properties that correspond to the fetched row, or FALSE if there aren't any a lot of rows 
mysql_fetch_row() fetches one row of information from the result related to the desired result symbol. The row is came back as AN array. every result column is keep in AN array offset, beginning at offset zero.

35. what's PHP?
Ans:
PHP Version three.0 is AN HTML-embedded scripting language. abundant of its syntax is borrowed from C, Java and Perl with a handful of distinctive PHP-specific options thrown in. The goal of the language is to permit internetdevelopers to jot down dynamically generated pages quickly.

36. what's the distinction between embrace and require?
Ans:
If you need a file and it can not be found, the script can terminate with a fatal error. If you employ embrace then {you can|you'll|you may} get miscalculation however the script will still execute. thus once the data you would like to reference from another file is crucial to the right running of a page, use need.

37. Is PHP a case sensitive programming language?
Ans:
PHP may be a partly case sensitive artificial language. we are able to use operate names, category names just in case insensitive manner.

38. what's mean by LAMP?
Ans:
LAMP means that combination of UNIX operating system, Apache, MySQL and PHP.

39.How does one get the user's science address in PHP?
Ans:
Using the server variable: $_SERVER['REMOTE_ADDR']

40. however does one build a technique cryptography for your passwords in PHP?
Ans:
Using md5 operate or sha1 operate

41. what's meant by PEAR in php?
Ans:
Answer1: PEAR is that the next revolution in PHP. This repository is transfer higher level programming to PHP. PEAR may be a framework and distribution system for reusable PHP elements. It eases installation by transfer an automaticwizard, and packing the strength and knowledge of PHP users into a nicely union OOP library. PEAR conjointlyprovides a command-line interface that may be accustomed mechanically install "packages" 
Answer2: 
PEAR is brief for "PHP Extension and Application Repository" and is pronounced similar to the fruit. the aim of PEAR is to provide: 
A structured library of open-sourced code for PHP users 
A system for code distribution and package maintenance 
A standard vogue for code written in PHP 
The PHP Foundation categories (PFC), 
The PHP Extension Community Library (PECL), 
A web site, mailing lists and transfer mirrors to support the PHP/PEAR community 
PEAR may be a community-driven project with the PEAR cluster because the organization. The project has been supported by Stig S. Bakken in 1999 and quite an heap of individuals have joined the project since then.

42. however will we have a tendency to repair a MySQL table?
Ans:
The syntex for repairing a mysql table is: 

REPAIR TABLE tablename 
REPAIR TABLE tablename fast 
REPAIR TABLE tablename EXTENDED 

This command can repair the table nominative. 
If fast is given, MySQL can do a repair of solely the index tree. 
If EXTENDED is given, it'll produce index row by row.

43. what's the distinction between echo and print statement?
Ans:
Echo() will take multiple expressions,Print cannot take multiple expressions. 

Print come back true or false supported success or failure whereas echo simply will what its told while not lease you recognize whether or not or not it worked properly.

44. What ar the options and benefits of OBJECT bound PROGRAMMING?
Ans:
One of the most benefits of OO programming is its simple modification; objects will simply be changed and added to a system there by reducing maintenance prices. OO programming is additionally thought-about to be higher at modeling the $64000 world than is procedural programming. It permits for a lot of difficult and versatile interactions. OO systems also are easier for non-technical personnel to grasp and easier for them to participate within themaintenance and improvement of a system as a result of it appeals to natural human psychological feature patterns.

Thanks!

0 comments: