2016-06-06

PHP (recursive acronym for PHP: Hypertext Preprocessor) interview questions and answers. 176 ~ Essential php interview questions and answers.These PHP Question and Answers for fresher / New employees.

PHP Interviews Question for Advance programmer. What is php ? what is Session ? All Answers list bellow its Answers commonly ask during interview for PHP Programmer.

PHP/PHP5 interview questions and answers for freshers~ Advance ~ Commonly ~ New Employees.

1. How can we display information of a variable and readable by human with PHP?

Answer: To be able to display a human-readable result we use print_r().

2. . What are escaping characters? Explain with an example?

Answer: Special characters are the characters that have some special meaning attached to it. Example is $, #, % etc. A backslash (\) before the special symbol is known as escaping characters. For example, two strings produce the same output: $string = 'The variable name is $var1'; $string = ''The variable name is \$var1''; The output from either string is the following: The variable name is $var1 Suppose you want to store a string as follows: $string = _Where is Tom'_s house_;

3. . Describe functions STRSTR() and STRISTR.

Answer: Both the functions are used to find the first occurrence of a string. Parameters includes: input String, string whose occurrence needs to be found, TRUE or FALSE (If TRUE, the functions return the string before the first occurrence. STRISTR is similar to STRSTR. However, it is case-insensitive E.g. strstr ($input_string, string)

4. . Why PHP is also called as Scripting language?

Answer: PHP is basically a general purpose language, which is used to write scripts. Scripts are normal computer files that consist of instructions written in PHP language. It tells the computer to execute the file and print the output on the screen. PHP is used for webpages and to create websites, thus included as scripting language.

5. What are the different errors in PHP?

Answer: There are 4 basically types of error. Parse Error � Commonly caused due to syntax mistakes in codes e.g. missing semicolon, mismatch brackets. Fatal Error � These are basically run time errors which are caused when you try to access what can�t be done. E.g. accessing a dead object, or trying to use a function that hasn�t been declared. Warning Error � These occurs when u try to include a file that is not present, or delete a file that is not on the server. This will not halt the script; it will give the notice and continue with the next line of the script. Notice Error � These errors occurs when u try to use a variable that hasn�t been declared, this will not halt the script, It will give the notice and continue with the next line of the script.

6. How is it possible to remove escape characters from a string?

Answer: The stripslashes function enables us to remove the escape characters before apostrophes in a string

7. What is needed to be able to use image function?

Answer: GD library is needed to be able execute image functions.

8. How is it possible to set an infinite execution time for PHP script?

Answer: The set_time_limit(0) added at the beginning of a script sets to infinite the time of execution to not have the PHP error �maximum execution time exceeded�.It is also possible to specify this in the php.ini file.

9. . Echo vs. print statement.

Answer: echo() and print() are language constructs in PHP, both are used to output strings. The speed of both statements is almost the same. echo() can take multiple expressions whereas print cannot take multiple expressions. Print return true or false based on success or failure whereas echo doesn't return true or false.

10. . Write a statement to show the joining of multiple comparisons in PHP?

Answer: PHP allows multiple comparisons to be grouped together to determine the condition of the statement. It can be done by using the following syntax: comparison1 and|or|xor comparison2 and|or|xor comparison3 and|or|xor. The operators that are used with comparisons are as follows: 1. and: result in positive when both comparisons are true. 2. or: result in positive when one of the comparisons or both of the comparisons are true. 3. xor: result in positive when one of the comparisons is

11. What is the use of the function ‘imagetypes()’?

Answer: imagetypes() gives the image format and types supported by the current version of GD-PHP.

12. . what is PDO ?

Answer: The PDO ( PHP Data Objects ) extension defines a lightweight, consistent interface for accessing databases in PHP. if you are using the PDO API, you could switch the database server you used, from say PgSQL to MySQL, and only need to make minor changes to your PHP code. While PDO has its advantages, such as a clean, simple, portable API but its main disadvantage is that it doesn't allow you to use all of the advanced features that are available in the latest versions of M

13. What is the difference between mysql_fetch_array() and mysql_fetch_assoc() ?

Answer: mysql_fetch_assoc function Fetch a result row as an associative array, While mysql_fetch_array() fetches an associative array, a numeric array, or both

14. What is cookie and why do we use it?

Answer: Cookie is a small piece of information stored in client browser. It is a technique used to identify a user using the information stored in their browser (if already visited that website) . Using PHP we can both set and get COOKIE.

15. . What are the various methods to pass data from one web page to another web page?

Answer: Different methods to pass data from one web page to another: 1. Store the data in a session variable. By storing the data, the data can be passed from one page to another. 2. Store data in a cookie: By storing data in a persistent cookie, data can be passed from one form to another. 3. Set the data in a hidden field and post the data using a submit button.

16. What is PEAR?

Answer: PEAR is a framework and distribution system for reusable PHP components.The project seeks to provide a structured library of code, maintain a system for distributing code and for managing code packages, and promote a standard coding style.PEAR is broken into three classes: PEAR Core Components, PEAR Packages, and PECL Packages. The Core Components include the base classes of PEAR and PEAR_Error, along with database, HTTP, logging, and e-mailing functions. The PEAR Packages include functionality providing for authentication, networking, and file system features, as well as tools for working with XML and HTML templates.

17. How do we get the current session ID?

Answer: session_start(); echo session_id();

18. . Explain the purpose of output buffering in PHP?

Answer: Output buffering in PHP buffers a scripts output. This buffer can be edited before returning it to the client. Without output buffering, PHP sends data to the web server as soon as it is ready. Output buffering "send" cookies at any point in the script. Cookies do not have to be necessarily sent near the start of page. Output buffers are stackable and hence sending to output is by choice.

19. How can we access the data sent through the URL with the GET method?

Answer: In order to access the data sent via the GET method, we you use $_GET array like this: www.url.com?var=value $variable = $_GET[�var�]; this will now contain �value�

20. . What does type casting mean in PHP? Explain with an example?

Answer: PHP automatically store the data and interprets according to itself. Type casting is a way to assign the variable according to your need and requirement and not allowing PHP to assign it automatically. To specify the type, it can be used like: $newint = (int) $var1; $newfloat = (float) $var1; $newstring = (string) $var1; The value in the variable on the right side of the equal sign is stored in the variable on the left side as the specified type.

21. What does accessing a class via :: means?

Answer: is used to access static methods that do not require object initialization

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

Answer: The main difference between $message and $$message is that former one is a simple variable and later is a reference variable. $message is a variable with a fixed name and it consists of a fixed value. $$messages contains the variable itself.

23. . what is session_set_save_handler in PHP?

Answer: 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

24. . Why PHP is sometimes called as embedded scripting language?

Answer: PHP is a high level language which is used to allow users to write and understand it in human readable form and also use an interpreter to interpret the code which user write for the computer. PHP is used as an embedded scripting language for the web. PHP is embedded in HTML code. HTML tags are used to enclose the PHP language. HTML is used and PHP is code written in it in the same way as you write JavaScript in HTML.

25. How is it possible to know the number of rows returned in result set?

Answer: The function mysql_num_rows() returns the number of rows in a result set.

26. what is the static variable in function useful for?

Answer: A static variable is defined within a function only the first time and its value can be modified during function calls as follows:

27. . Short note on passing parameter by reference and returning parameter by reference with examples.

Answer: Passing parameter by reference: In PHP, variables can be passed by reference so as to modify them. Variables, statements which have new and references returned from function can be passed. Example: references returned from function <?php Function &sample() { $a =1; Return &a; } Foo(bar()); ?> Returning parameter by reference: Returning parameter by reference is used when a function to find to which variable a reference should be bound. Example:

28. . What is zend engine in PHP?

Answer: Zend engine is like a virtual machine and is an open source, and is known for its role in automating the web using PHP. Zend is named after its developers Zeev and Aandi. Its reliability, performance and extensibility has a significant role in increasing the PHP's popularity. The Zend Engine II is the heart of PHP 5. It is an open source project and freely available under BSD style license.

29. How can we check the value of a given variable is a number?

Answer: It is possible to use the dedicated function, is_numeric() to check whether it is a number or not.

30. What does the unset() function means?

Answer: The unset() function is dedicated for variable management. It will make a variable undefined.

31. How can you pass a variable by reference?

Answer: To be able to pass a variable by reference, we use an ampersand in front of it, as follows $var1 = &$var2

32. What function do we use to find length of string, and length of array?

Answer: For finding length of string we use strlen() function and for array we use count() function.

33. What does the unlink() function means?

Answer: The unlink() function is dedicated for file system handling. It simply deletes the file given as entry.

34. . What is MIME?

Answer: MIME - Multi-purpose Internet Mail Extensions. MIME types represents a standard way of classifying file types over Internet. Web servers and browsers have a list of MIME types, which facilitates files transfer of the same type in the same way, irrespective of operating system they are working in. A MIME type has two parts

35. . What is meant by PEAR in php? What is the purpose of it?

Answer: PEAR stands for "PHP Extension and Application Repository". As the name suggests, it gives advanced functionality to the PHP language and include many applications which can be used on fly. The purpose of it is as follows:- - Open source structured library for PHP users - Code distribution and package maintenance system - Standard style for code written in PHP

36. What is the difference between include(), include_once() and require_once()

Answer: The include() statement includes and evaluates a specified line i.e. it will include a file based in the given path. require() does the same thing expect upon failure it will generate a fatal error and halt the script whereas include() will just gives a warning and allow script to continue. require_once() will check if the file already has been included and if so it will not include the file again.

37. What are the functions to be used to get the image’s properties (size, width and height)?

Answer: The functions are getimagesize() for size, imagesx() for width and imagesy() for height

38. What is Open Source Software?

Answer: Software in which the source codes are freely used, modify, and shared by anyone are called Open Source Software. These can also be distributed under licenses that adhere with the Open Source Definition.

39. What is session and why do we use it?

Answer: Session is a super global variable that preserve data across subsequent pages. Session uniquely defines each user with a session ID, so it helps making customized web application where user tracking is needed.

40. what is the use of rand() in php?

Answer: It is used to generate random numbers.If called without the arguments it returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 6 and 12 (inclusive), for example, use rand(6, 12).This function does not generate cryptographically safe values, and should not be used for cryptographic uses. If you want a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead.

41. . How PHP statement is different from PHP script?

Answer: The difference between PHP statement and PHP script is that statements are set of instructions that tell PHP to perform an action. PHP script consists of a series of PHP statements that it uses for execution. PHP executes statements one at a time till it reaches the end of the script. Example is as follows: PHP statement: echo ''Hi''; PHP script: if (time = midnight) {put on pajamas; brush teeth; go to bed;}

42. What does the initials of PHP stand for?

Answer: PHP means PHP: Hypertext Preprocessor.

43. . What is the difference between Notify URL and Return URL?

Answer: Notify URL and Return URL is used in Paypal Payment Gateway integration. Notify URL is used by PayPal to post information about the transaction. Return URL is sued by the browser; A url where the user needs to be redirected on completion of the payment process.

44. How do I check if a given variable is empty?

Answer: If we want to check whether a variable has a value or not, it is possible to use the empty() function.

45. What is the difference between explode() and split() functions?

Answer: Both are used to split a string to array, the basic difference is that split() uses pattern for splitting and explode() uses a string. explode() is faster than split() as it does not match the string based on regular expression. Also split() is deprecated as of 5.3.0. So using of this function is discouraged.

46. . How to upload files using PHP?

Answer: - Select a file from the form using <inupt type=''file''> - Specify the path into which the file is to be stored. - Insert the following code in php script to upload the file. move_uploaded_file($_FILES["file"]["tmp_name"], "myfolder/" . $_FILES["file"]["name"]);

47. . What is the difference between echo and print statement in PHP?

Answer: Multiple expressions can be given in echo statement, where as print cannot take multiple expressions. Echo does not have a return value, where as print returns a value indicating successful execution. Echo is faster when compared with print.

48. What is PHP?

Answer: PHP is a web language based on scripts that allows developers to dynamically create generated web pages.

49. When a conditional statement is ended with an endif?

Answer: When the original if was followed by : and then the code block without braces.

50. How comparison of objects is done in PHP?

Answer: We use the operator �==� to test is two object are instanced from the same class and have same attributes and equal values. We can test if two object are refering to the same instance of the same class by the use of the identity operator �===�.

51. . Why IDE is recommended for use while programming with PHP?

Answer: IDE stands for Integrated Development environment; it is a framework for developing applications. It includes programming editor where you can edit and write the development programs. The features of IDE are as follows: 1. Debugging: this is the feature which is used to debug or find the bugs in a program 2. Preview: this is the feature which allow instant preview of the program you are writing 3. Testing: this is the features that includes built in testing features through whic

52. . How many ways I can redirect a PHP page?

Answer: a. Header function in PHP redirects to a new URL Example: <?php header("Location: http://www.redirecturl.com/"); ?> b. http_redirect() is also used to redirect to a new page or URL. Syntax void http_redirect ( [string url [, array params [, bool session = FALSE [, int status]]]] ) Here, the URL is the path of the new page. params can be some query parameters followed by whether the session information needs to be passed and the custom response status code.

53.  ) What does the PHP error ‘Parse error in PHP – unexpected T_variable at line x’ means?

Answer: This is a PHP syntax error expressing that a mistake at the line x stops parsing and executing the program.

54. . How to set cookies in PHP?

Answer: The function setcookie() is used to define a cookie that is to be sent along with HTTP headers. The cookie must be sent prior to any output from the script as is the protocol restriction. After setting the cookies, they can be used when the next page is loaded by using $_COOKIE or $HTTP_COOKIE_VARS arrays.

55. Is multiple inheritance supported in PHP?

Answer: PHP includes only single inheritance, it means that a class can be extended from only one single class using the keyword �extended�.

56. . What is the use of $_Server and $_Env?

Answer: $_SERVER and $_ENV arrays contain different information. The information depends on the server and operating system being used. Most of the information can be seen of an array for a particular server and operating system. The syntax is as follows: foreach($_SERVER as $key =>$value) { echo ''Key=$key, Value=$value\n''; }

57. How do we destroy a session.

Answer: session_start(); �session_destroy();

58. . Echo vs. print statement?

Answer: echo() and print() are language constructs in PHP, both are used to output strings. The speed of both statements is almost the same. echo() can take multiple expressions whereas print cannot take multiple expressions. Print return true or false based on success or failure whereas echo doesn't return true or false.

59. How do I escape data before storing it into the database?

Answer: addslashes function enables us to escape data before storage into the database.

60. What should we do to be able to export data into an Excel file?

Answer: The most common and used way is to get data into a format supported by Excel. For example, it is possible to write a .csv file, to choose for example comma as separator between fields and then to open the file with Excel

61. How is it possible to cast types in PHP?

Answer: The name of the output type have to be specified in parentheses before the variable which is to be cast as follows: * (int), (integer) � cast to integer * (bool), (boolean) � cast to boolean * (float), (double), (real) � cast to float * (string) � cast to string * (array) � cast to array * (object) � cast to object

62. Differences between GET, POST and REQUEST methods ?

Answer: GET and POST are used to send information from client browser to web server. In case of GET the information is send via GET method in name/value pair and is URL encoded. The default GET has a limit of 512 characters. The POST method transfers the information via HTTP Headers. The POST method does not have any restriction in data size to be sent. POST is used for sending data securely and ASCII and binary type�s data. The $_REQUEST contains the content of both $_GET, $_POST and $_COOKIE.

63. What is an associative array?

Answer: Associative arrays are arrays that use named keys that you assign to them. "New Delhi","China"=>"Beijing","Pakistan"=>"Islamabad"); ?>

64. What does PEAR stands for?

Answer: PEAR means �PHP Extension and Application Repository�. it extends PHP and provides a higher level of programming for web developers.

65. . What are the differences between public, private, protected, static, transient, final and volatile?

Answer: Public: Public declared items can be accessed everywhere. Protected: Protected limits access to inherited and parent classes (and to the class that defines the item). Private: Private limits visibility only to the class that defines the item. Static: A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope. Final: Final keyword prevents child classes from overriding a method by prefixing the defini

66. . How the web server interprets PHP and interacts with the client?

Answer: After installing and configuring the PHP, the web When PHP is installed, the Web server looks for PHP code that is embedded in HTML file with its extension. The extensions which are used are .php or .phtml. When web server receives a request for the file with an appropriate extension, HTML statements are processed and PHP statements are executed on the server itself. When the processing gets over the output is being shown in HTML statements.

67. . What is the use of PEAR in php?

Answer: PEAR is known as PHP Extension and Application Repository. It provides structured library to the PHP users and also gives provision for package maintenance.

68. How can we automatically escape incoming data?

Answer: We have to enable the Magic quotes entry in the configuration file of PHP.

69. How can we check the value of a given variable is alphanumeric?

Answer: It is possible to use the dedicated function, ctype_alnum to check whether it is an alphanumeric value or not.

70. What is the difference between mysql_fetch_object() and mysql_fetch_array()?

Answer: The mysql_fetch_object() function collects the first single matching record where mysql_fetch_array() collects all matching records from the table in an array

71. If the variable $var is set to and the $var is set to the character var, what’s the value of $$var?

Answer: $$var2 contains the value 10.

72. . Explain how to submit form without a submit button in PHP.

Answer: A form can be submitted in various ways without using submit button. Submitting a form by clicking a link Submitting a form by selecting an option from drop down box with the invocation of onChange event Using java script : document.form.submit(); Using header(''location:page.php'');

73. How a constant is defined in a PHP script?

Answer: The define() directive lets us defining a constant as follows: define (�ACONSTANT�, 123);

74. What is the difference between javascript and PHP?

Answer: Javascript is a client side scripting language whereas PHP is a server side scripting language.

75. What is the difference between Session and Cookie?

Answer: The main difference between sessions and cookies is that sessions are stored on the server, and cookies are stored on the user�s computers in the text file format. Cookies can not hold multiple variables,But Session can hold multiple variables.We can set expiry for a cookie,The session only remains active as long as the browser is open.Users do not have access to the data you stored in Session,Since it is stored in the server.Session is mainly used for login/logout purpose while cookies using for user activity tracking

76. . What are the features and advantages of object-oriented programming?

Answer: One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a

77. What is the actually used PHP version?

Answer: Version 5 is the actually used version of PHP

78. How the result set of Mysql be handled in PHP?

Answer: The result set can be handled using mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_object or mysql_fetch_row.

79. . What type of inheritance that PHP supports?

Answer: In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.

80. . What are the different tables(Engine) present in MySQL,which one is default?

Answer: Following tables (Storage Engine) we can create 1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. ) 2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commi

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

Answer: 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

82. What is the main difference between require() and require_once()?

Answer: require() and require_once() perform the same task except that the second function checks if the PHP script is already included or not before executing it (same for include_once() and include())

83. Which programming language does PHP resemble to?

Answer: PHP syntax resembles Perl and C

84. . How many different types of messages available in PHP?

Answer: 1. Error message: is received when the script has some problem that is preventing it from running correctly. The message consists of the possible solution or identification of the problem. Ex: Parse error: occurs when there is something gets missed while writing the script. 2. Warning message: is received when the script find out some problem that doesn't allow the script to run. These messages are not of very high priority but quite essential to show that there is something wrong wit

85. . Explain the differences between require and include, include_once?

Answer: Include() will include the file specified. Include_once() will include the file only once even if the code of the file has been included before. Require() and include() are the same with respect to handling failures. However, require() results in a fatal error and does not allow the processing of the page.

86. . Explain the difference between $message and $$message in PHP

Answer: $message is a variable and $$message is a variable of another variable. For example $Message = "YOU"; $you= "Me"; echo $message //Output:- you echo $$message //output :-Me $$message allows the developer to change the name of the variable dynamically.

87. . What is CAPTCHA in PHP?

Answer: Captcha are images with some characters/ digits on it. One need to type the characters or digits in the text box for the purpose of submitting. This avoids automatic submitting by an operation by other programs or a robot.

88. . how to track user logged out or not? when user is idle ?

Answer: By checking the session variable exist or not while loading th page. As the session will exist longer as till browser closes. The default behaviour for sessions is to keep a session open indefinitely and only to expire a session when the browser is closed. This behaviour can be changed in the php.ini file by altering the line session.cookie_lifetime = 0 to a value in seconds. If you wanted the session to finish in 5 minutes you would set this to session.cookie_lifetime = 300

89. How can we define a variable accessible in functions of a PHP script?

Answer: This feature is possible using the global keyword.

90. How is the ternary conditional operator used in PHP?

Answer: It is composed of three expressions: a condition, and two operands describing what instruction should be performed when the specified condition is true or false as follows: Expression_1 ? Expression_2 : Expression_3;

91. . What is the difference between the functions unlink and unset in PHP?

Answer: The function unlink() is to remove a file, where as unset() is used for destroying a variable that was declared earlier. unset() empties a variable or contents of file.

92. Distinguish between urlencode and urldecode?

Answer: This method is best when encode a string to used in a query part of a url. it returns a string in which all non-alphanumeric characters except -_. have replece with a percentege(%) sign . the urldecode->Decodes url to encode string as any %and other symbole are decode by the use of the urldecode() function.

93. How can we display the output directly to the browser?

Answer: To be able to display the output directly to the browser, we have to use the special tags

94. . What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading?

Answer: Move: This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination. If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE. Copy: Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise

95. . PHP being an open source is there any support available to it?

Answer: PHP is an open source language, and it is been said that it has very less support online and offline. But, PHP is all together a different language that is being developed by group of programmers, who writes the code. There is lots of available support for PHP, which mostly comes from developers and PHP users.

96. . What is a PHP Session?

Answer: What is a PHP Session?

PHP session allows you to store the user session, like their information on server for faster access and for later use like username, IP addresses, their actions etc. The information which is saved is temporary and can be deleted after the user is no longer active. Example of starting a PHP session is as follows: <?php session_start(); // start up your PHP session! ?>

97. How can we access the data sent through the URL with the POST method?

Answer: To access the data sent this way, you use the $_POST array. Imagine you have a form field called �var� on the form, when the user clicks submit to the post form, you can then access the value like this: $_POST[�var�];

98. What are the correct and the most two common way to start and finish a PHP block of code?

Answer: The two most common ways to start and finish a PHP script are: and

99. . How do you create sub domains using PHP?

Answer:

Wild card domains can be used. Sub domains can be created by first creating a sub directory in the /htdocs folder. E.g. /htdocs/mydomain. Then, the host file needs to be modified to define the sub domain. If the sub domains are not configured explicitly, all requests should be thrown to the main domain.

100. . what are magic methods?

Answer: Magic methods are the members functions that is available to all the instance of class Magic methods always starts with "__". Eg. __construct All magic methods needs to be declared as public To use magic method they should be defined within the class or program scope Various Magic Methods used in PHP 5 are: __construct() __destruct() __set() __get() __call() __toString() __sleep() __wakeup() __isset() __unset() __autoload() __clone()

101. How can we connect to a MySQL database from a PHP script?

Answer: To be able to connect to a MySQL database, we must use mysql_connect() function as follows:

102. . What is the difference between echo, print and printf()?

Answer: Echo is the basic type used to print out a string. It just shows the content of the message written using it. It can have multiple parameters as well. print is a construct, it returns TRUE on successful output and FALSE there is no output. It can't have multiple parameters. Printf() is a function, and not be used as a construct. It allows the string output to be formatted. It is the slowest medium to print the data out.

103. How can PHP and HTML interact?

Answer: It is possible to generate HTML through PHP scripts, and it is possible to pass informations from HTML to PHP.

104. In PHP, objects are they passed by value or by reference?

Answer: In PHP, objects passed by value.

105. Which function gives us the number of affected entries by a query?

Answer: mysql_affected_rows() return the number of entries affected by an SQL query

106. What does the function get_magic_quotes_gpc() means?

Answer: The function get_magic_quotes_gpc() tells us whether the magic quotes is switched on or no.

107. Which cryptographic extension provide generation and verification of digital signatures?

Answer: The PHP-openssl extension provides several cryptographic operations including generation and verification of digital signatures.

108. What is the function func_num_args() used for?

Answer: The function func_num_args() is used to give the number of parameters passed into a function.

109. . What is a Persistent Cookie?

Answer: Cookies are used to remember the users. Content of a Persistent cookie remains unchanged even when the browser is closed. 'Remember me' generally used for login is the best example for Persistent Cookie.

110. . What is the functionality of the function htmlentities?

Answer: 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

111. . What are the steps involved to run PHP?

Answer: The steps which are involved and required to run PHP is as follows: 1. Set up the web environment. 2. Set up the web servers. There are many web servers that are available and the mostly used is Apaches which automatically remains installed with linux distribution and on windows it is easy to install. There are other servers like IIS (Internet information server) provided by Microsoft can be used to set up the web environment. 3. Install the web server and PHP 4. Update and

112. . How error handling is being handled by PHP?

Answer: Error handling is very important in every programming language. PHP uses the trigger to print the error in a program. The example statement is given below: If ($height_of_door > $height_of_house) { trigger_error(''Impossible condition'',E_USER_ERROR); } The E_USER_ERROR in the statement tells PHP that the condition is an error. Impossible condition is a string message which is displayed when an error is encountered. If the condition comes out to be true then the following mes

113. What is the function mysql_pconnect() usefull for?

Answer: mysql_pconnect() ensure a persistent connection to the database, it means that the connection do not close when the the PHP script ends

114. . How can we increase the execution time of a PHP script?

Answer: By default the PHP script takes 30secs to execute. This time is set in the php.ini file. This time can be increased by modifying the max_execution_time in seconds. The time must be changed keeping the environment of the server. This is because modifying the execution time will affect all the sites hosted by the server.

115. . How to create reusable code in PHP?

Answer: Applications created in PHP often perform the same task in same script or in different scripts. To create a reusable code functions are used. Functions are group of PHP statements that perform a specific task. Example: A header and footer can be created for all the web pages which has to be used again and again. echo '<img src=''greenrule.jpg'' width=''100%'' height=''7'' /> <address>My Great Company <br />1234 Wonderful Rd. <br />San Diego, CA 92126 &

116. . What is the difference between Split and Explode in PHP?

Answer: T

Show more