Junior PHP Developer

  Home  Web Development  Junior PHP Developer


“Junior PHP Developer related Frequently Asked Questions in various Junior PHP Developer job interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting”



161 Junior PHP Developer Questions And Answers

21⟩ Explain me what is the use of 'print' in php?

This is not actually a real function, It is a language construct. So you can use with out parentheses with its argument list.

Example

print('PHP Interview questions');

print 'Job Interview ';

 178 views

24⟩ Tell me what is the use of explode() function?

Syntax :

array explode ( string $delimiter , string $string [, int $limit ] );

This function breaks a string into an array. Each of the array elements is a substring of string formed by splitting it on boundaries formed by the string delimiter.

 140 views

25⟩ Explain me what is the importance of "method" attribute in a html form?

"method" attribute determines how to send the form-data into the server. There are two methods, get and post. The default method is get. This sends the form information by appending it on the URL. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

 117 views

26⟩ Tell me what are the different types of errors in PHP?

Here are three basic types of runtime errors in PHP:

☛ 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 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.

 118 views

30⟩ Explain what is the static variable in function useful for?

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

<!--?php

function testFunction()

{

static $testVariable = 1;

echo $testVariable;

$testVariable++;

}

testFunction(); //1

testFunction(); //2

testFunction(); //3

?-->

 143 views

31⟩ What is faster in PHP?

1- Combining two variables as follows:

$variable1 = ‘Hello ‘;

$variable2 = ‘World’;

$variable3 = $variable1.$variable2;

Or

2- $variable3 = “$variable1$variable2”;

$variable3 will contain “Hello World”. The first code is faster than the second code especially for large large sets of data.

 139 views

33⟩ Explain how is it possible to cast types in PHP?

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

 152 views

37⟩ Explain me difference between mysql_connect and mysql_pconnect?

There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends. mysql_connect() provides only for the database new connection while using mysql_pconnect, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection... the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

 178 views

39⟩ What is difference between require_once(), require(), include()?

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

 147 views