Php Interview Questions Together With Answers

1) What is the departure betwixt strstr & stristr?

For strstr, the syntax is: string strstr(string $string,string $str ); The share strstr volition search $str inward $string. If it finds the string agency it volition homecoming string from where it finds the $str upto terminate of $string.

For Example:



$string = "http://yahoomail.com";
$str="yahoomail";

The output is "yahoomail.com". The principal departure betwixt strstr together with stristr is of instance sensitivity. The sometime consider the instance departure together with afterwards ignore the instance difference. 


2) What is the departure betwixt explode together with split?


Split share splits string into array past times regular expression. Explode splits a string into array past times string.

For Example:



explode(" and", "India together with Islamic Republic of Pakistan together with Srilanka");
split(" :", "India : Islamic Republic of Pakistan : Srilanka");

Both of these functions volition homecoming an array that contains India, Pakistan, together with Srilanka.
 If it finds the string agency it volition homecoming string from where it finds the  PHP Interview Questions together with Answers
PHP Interview Questions together with Answers


3) How tin you lot avoid execution fourth dimension out fault spell fetching tape from MySQL?

set_time_limit -- Limits the maximum execution time

For Example:

set_time_limit(0);

If you lot laid to 0 you lot say that at that spot is non limit.

4) Write a SQL query that displays the departure betwixt the highest together with lowest salaries of a database tabular array "employees". Label the column equally DIFFERENCE. 

Select max(sal)-min(sal) equally Difference from employees;

5) What is the departure betwixt require() together with include()?

Both of these constructs includes together with evaluates the specific file. The ii functions are identical inward every way except how they handgrip failure. If filepath non found, require() terminates the computer program together with gives fatal error, but include() does non terminate the program; It gives alert message together with continues to program.

include() produces a Warning spell require() results inward a Fatal Error if the filepath is non correct.

6) What is the departure betwixt echo together with print?

Main departure betwixt echo() together with print() is that echo is exactly an declaration non a share together with doesn't return's value or it exactly prints a value whereas print() is an share which prints a value together with equally good it returns value.

We cannot exceed arguments to echo since it is exactly a declaration whereas impress is a share together with nosotros tin exceed arguments to it together with it returns truthful or false. impress tin live on used equally share of a to a greater extent than complex seem whereas echo cannot. echo is marginally faster since it doesn't laid a homecoming value.

7) An examiner awards the highest grade 75 together with the lowest grade 25, the exceed marks beingness 40. The moderator wants to modify the highest grade to 250 together with the lowest marks to 100 using the linear formula y=ax+b. The revised exceed marks volition be:

A. 145
B. 150
C. 160
D. 400/3

Give the right option.

y=ax+b
100=25a+b
250=75a+b

Solve it instruct together with b together with and thus put

y=40a+b

Answer: 145

8) H5N1 together with B are shooters together with having their exam. H5N1 together with B autumn curt of 10 together with 2 shots respectively to the qualifying mark. If each of them fired at to the lowest degree ane shot together with fifty-fifty past times adding their full score together, they autumn curt of the qualifying mark, what is the qualifying mark?

Answer: 11

As H5N1 is curt past times 10 - he has shot 1

As B is curt past times 2 - he has shot 9

9+1=10 together with 10 < 11

9) In objective bear witness a right reply score iv marks together with on a incorrect reply 2 marks. H5N1 pupil scores 480 marks from 150 questions. How many answers were correct?

A. 120
B. 130
C. 110
D. 150

Answer: B i.e. 130
4x-2y=480
x+y=150

Then X is 130 thus 130 is right answer.

10) An INK põrnikas starts jumping 1 meter to each management north, south, eastward together with due west respectively. It marks a signal inward the novel locations. It comes dorsum to its master copy signal after jumping inward all directions. It ane time again starts the same procedure from the newly drawn unique points. Totally how many points did the põrnikas mark?

11) H5N1 guy walks at 4kmph from a point. After 4hrs a cyclist starts from the same signal at 10kmph. At what distance volition they run into from the starting point?

Answer: 26.66km

Explanation: We have, s=vt where s=distance. Since both run into at same point, both travels same distance=s km. Now, equating, 10(t+4) = 4t ------> t=20/3

sub. t=20/3 inward s=4t---------> s = 26.66km

12) What's the departure betwixt COPY OF H5N1 FILE & MOVE_UPLOAD_FILE inward file uploading?

Move: This share checks to ensure that the file designated past times filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it volition live on moved to the filename given past times destination.

If filename is non a valid upload file, together with thus no activity volition occur, together with move_uploaded_file() volition homecoming FALSE.

Copy: Makes a re-create of a file. Returns TRUE if the re-create succeeded, FALSE otherwise.

13) How exercise you lot insert unmarried & double quotes inward MySQL db without using PHP?

&amp; / &quote;

Alternately, escape unmarried quote using forwards slash \' . In double quote you lot don't involve to escape quotes. Insert double quotes equally "".



14) What exercise you lot involve to exercise to improve the performance (speedy execution) for the script you lot receive got written?

If your script is to call back information from Database, you lot should work "Limit" syntax. Break downwards the non dynamic sections of website which involve non live on repeated over a menstruation of fourth dimension equally include files.


15) How exercise you lot capture audio/video inward PHP?

You involve a module installed - FFMPEG. FFmpeg is a consummate solution to record, convert together with flow good together with video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed nether Linux, but it tin live on compiled nether most operating systems, including Windows.

16) How exercise you lot know (status) whether the recipient of your post service had opened the post service i.e. read the mail?

Embed an URL inward a say 0-byte picture tag may live on the ameliorate way to go. In other word, you lot embed an invisible picture on you lot html e-mail together with when the src URL is beingness rendered past times the server, you lot tin rails whether your recipients receive got sentiment the emails or not.

17) What is random number?

A random publish is a publish generated past times a process, whose termination is unpredictable, together with which cannot live on sub sequentially reliably reproduced.

18) What is departure betwixt srand & shuffle?

The srand share seeds the random publish generator amongst seed together with shuffle is used for shuffling the array values.
shuffle - This share shuffles (randomizes the lodge of the elements in) an array. This share assigns novel keys for the elements inward array. It volition take away whatsoever existing keys you lot may receive got assigned, rather than exactly reordering the keys.

srand - Seed the random publish generator

19) How tin nosotros take away duplicate values from an array?

array_unique() funciton tin live on used for the purpose.

20) How exercise I uncovering out weather condition a publish is strange or even?

if (number%2==0 ) together with thus fifty-fifty else odd.

21) How tin nosotros instruct the ID generated from the previous insert operation?

SELECT MAX(ID) from tablename;

22) How to bound the publish of rows to five that I exit of my database?

Select * from tablename LIMIT 0, 5;

23) How to shop binary information inward MySQL?

Use BLOB information type for the database field.

24) How tin nosotros submit a cast without a submit button?

We tin submit a cast using the JavaScript. Example: document.formname.submit();

25) How tin I maintain the count of how many persons receive got hitting my site?

26) What is departure betwixt mysql_fetch_array(), mysql_fetch_row() together with mysql_fetch_object()?

mysql_fetch_array - Fetch the all matching records of results.
mysql_fetch_object - Fetch the outset unmarried matching tape of results.
mysql_fetch_row - fetches a termination row equally array.

27) How to brand a download page inward ain site, where I tin know that how many file has been loaded past times item user or item IP address?

We tin log the IP addresses inward ane database tabular array spell downloading the file. This way nosotros tin count together with banking concern check the no. of rows inserted for a item download.

28) What is departure betwixt mysql_connect together with mysql_pconnect?

mysql_connect opens upward a database connexion every fourth dimension a page is loaded. mysql_pconnect opens upward a connection, together with keeps it opened upward across multiple requests.

mysql_pconnect uses less resources, because it does non involve to institute a database connexion every fourth dimension a page is loaded.

29) What is the departure betwixt “Insert”, “Update” together with “Modify” events?

INSERT - Add a novel tape into the database table.

MODIFY - If tape is available it modifies otherwise it wont modify.

UPDATE - If tape is available it updates the tape otherwise it creates a novel record.

30) How I tin instruct IP address?

getenv("REMOTE_ADDR");



31) How to brand a login page where ane time the user has logged inward volition instruct dorsum to the page it came from to login page? 

32) How exercise nosotros know properties of the browser?

You tin assemble a lot of information well-nigh a person's reckoner past times using $_SERVER['HTTP_USER_AGENT']. This tin tell us to a greater extent than well-nigh the user's operating system, equally good equally their browser. For instance I am revealed to live on Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, similar Gecko) Safari/417.9.3 when visiting a PHP page.

This tin live on useful to programmers if they are using exceptional features that may non piece of work for everyone, or if they desire to instruct an thought of their target audience. This equally good is of import when using the get_browser() share for finding out to a greater extent than information well-nigh the browser's capabilities. By having this information the user tin live on directed to a version of your site best suited to their browser.

get_browser() attempts to decide the capabilities of the user's browser. This is done past times looking upward the browser's information inward the browscap.ini file.

echo $_SERVER['HTTP_USER_AGENT'] . "<hr />\n";
$browser = get_browser();
foreach ($browser equally $name => $value)
{
echo "<b>$name</b> $value <br />\n";
}

33) What is departure betwixt require_once(), require(), include(). Because all these share are used to telephone band a file inward exactly about other file.


Difference betwixt require() together with require_once(): require() includes together with evaluates a specific file, spell require_once() does that solely if it has non been included before (on the same page).


So, require_once() is recommended to work when you lot desire to include a file where you lot receive got a lot of functions for example. This way you lot brand certain you lot don't include the file to a greater extent than times together with you lot volition non instruct the "function re-declared" error.


Difference betwixt require() together with include() is that require() produces a FATAL ERROR if the file you lot desire to include is non found, spell include() solely produces a WARNING.


There is equally good include_once() which is the same equally include(), but the departure betwixt them is the same equally the departure betwixt require() together with require_once().



34) If you lot receive got to piece of work amongst dates inward the next format: "Tuesday, Feb 14, 2006 @ 10:39 am", how tin you lot convert them to exactly about other format that is easier to use?

The strtotime share tin convert a string to a timestamp.
A timestamp tin live on converted to appointment format. So it is best to shop the dates equally timestamp inward the database, together with exactly output them inward the format you lot like.

So let's say nosotros receive got $date = "Tuesday, Feb 14, 2006 @ 10:39 am";
In lodge to convert that to a timestamp, nosotros involve to instruct rid of the "@" sign, together with nosotros tin work the remaining string equally a parameter for the strtotime function.

So nosotros have

$date = str_replace("@ ","",$date);
$date = strtotime($date);
Now $date is a timestamp together with nosotros tin say:
echo date("d thou Y",$date);


35) What is CAPTCHA? 

CAPTCHA stands for Completely Automated Public Turing Test to tell Computers together with Humans Apart. To preclude spammers from using bots to automatically fill upward out forms, CAPTCHA programmers volition generate an picture containing distorted images of a string of numbers together with letters. Computers cannot decide what the numbers together with letters are from the picture but humans receive got smashing pattern recognition abilities together with volition live on able to fairly accurately decide the string of numbers together with letters. By entering the numbers together with letters from the picture inward the validation field, the application tin live on fairly assured that at that spot is a human customer using it.

36) What is the departure betwixt sessions together with cookies?

37) What is the departure betwixt $x together with $$x ?

$x is uncomplicated variable. $$x is reference variable or infact a variable of variable. H5N1 variable variable allows us to modify the refer of a variable dynamically.

<?
$x = "this";
$$x = "is cake";
?>
The $$ is the syntax used inward PHP for a variable variable. I tin straight off telephone band the ii variables $x together with $$x two
ways.
<?
echo "$x ${$x}";
?>
<?
echo "$x $this";
?>

Both of these volition homecoming the string "this is cake". Notice that $$x is written equally ${$x} inward echo. This lets PHP know that you lot are using the variable $$x together with non $ together with $x



38) What is meant past times nl2br()?

New line of piece of work (\n) to Break tag (<BR>) conversion.

39) What are the electrical flow versions of apache, PHP, together with MySQL?

40) What are the reasons for selecting light (Linux, Apache, MySQL, PHP) instead of combination of other software programs, servers together with operating systems?

41) How tin nosotros encrypt together with decrypt a information acquaint inward a MySQL tabular array using MySQL?

AES_ENCRYPT(str,key_str) , AES_DECRYPT(crypt_str,key_str)


42) What are the differences betwixt Get together with post methods inward cast submitting, give the instance where nosotros tin work instruct together with nosotros tin work post methods? 

43) What does PHP stands for together with who is the manlike soul nurture of PHP? Explain the changes inward PHP versions?

44) How tin nosotros exercise a database using PHP together with MySQL?

45) What is meant past times urlencode() together with urldecode()?

string urlencode(str)

When str contains a string similar this “hello world” together with the homecoming value volition live on URL encoded together with tin live on work to append amongst URLs, commonly used to append information for GET similar someurl.com?var=hello%world

string urldocode(str)

This volition uncomplicated decode the GET variable’s value. Example: echo (urldecode($_GET_VARS[var])) volition output
“hello world”

46) What is the departure betwixt the functions unlink together with unset?

unlink is a share for file arrangement handling. It volition only delete the file inward context. unset volition laid UNSET the specified variable.

unlink is used to delete a file. unset is used to destroy an before declared variable.

47) What are the unlike types of errors inward PHP?

1. Notices: These are trivial, non-critical errors that PHP encounters spell executing a script - for example, accessing a variable that has non nevertheless been defined. By default, such errors are non displayed to the user at all - although you lot tin modify this default behavior.

2. Warnings: These are to a greater extent than serious errors - for example, attempting to include() a file which does non exist. By default, these errors are displayed to the user, but they exercise non termination inward 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 drive the immediate termination of the script, together with PHP’s default conduct is to display them to the user when they receive got place.

48) How tin nosotros exercise a session variable & terminate it?

$_SESSION[’name’] = “Chinmay”;

To destroy a session: unset($_SESSION[’name’]);



49) How to Create a Cookie & destroy it inward PHP?

setcookie(”variable”,”value”,”time”);

variable - refer of the cookie variable
variable - value of the cookie variable
time - decease time

Example: setcookie(”test”,$i,time()+3600);

Test - cookie variable name
$i - value of the variable ‘Test’
time()+3600 - denotes that the cookie volition expire after an ane hour.
Destroy a cookie past times specifying decease time
Example: setcookie(”test”,$i,time()-3600); // already expired time
Reset a cookie past times specifying its refer only
setcookie(”test”);

50) What is the departure betwixt sizeof($array) together with count($array)? 

sizeof($array) - This share is an alias of count()
count($array) - If you lot exactly exceed a uncomplicated variable instead of an array it volition homecoming 1.

Komentar

Postingan populer dari blog ini

Add Privacy Policy To Blogger Footer Pace Past Times Pace Tutorial

Search Engine Optimization

Definitive Conduct To Seo Inwards 2018