1) What is the divergence betwixt strstr & stristr?
For strstr, the syntax is: string strstr(string $string,string $str ); The part strstr volition search $str inwards $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 top dog divergence betwixt strstr together with stristr is of instance sensitivity. The one-time consider the instance divergence together with afterwards ignore the instance difference.
2) What is the divergence betwixt explode together with split?
Split part 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.
PHP Interview Questions together with Answers |
3) How tin you lot avoid execution fourth dimension out fault piece 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 topographic point is non limit.
4) Write a SQL query that displays the divergence betwixt the highest together with lowest salaries of a database tabular array "employees". Label the column every bit DIFFERENCE.
Select max(sal)-min(sal) every bit Difference from employees;
5) What is the divergence betwixt require() together with include()?
Both of these constructs includes together with evaluates the specific file. The 2 functions are identical inwards every way except how they grip failure. If filepath non found, require() terminates the programme 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 piece require() results inwards a Fatal Error if the filepath is non correct.
6) What is the divergence betwixt echo together with print?
Main divergence betwixt echo() together with print() is that echo is precisely an declaration non a part together with doesn't return's value or it precisely prints a value whereas print() is an part which prints a value together with likewise it returns value.
We cannot top arguments to echo since it is precisely a declaration whereas impress is a part together with nosotros tin top arguments to it together with it returns truthful or false. impress tin go used every bit part of a to a greater extent than complex aspect 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 top marks beingness 40. The moderator wants to alter the highest grade to 250 together with the lowest marks to 100 using the linear formula y=ax+b. The revised top 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 teach together with b together with therefore put
y=40a+b
Answer: 145
8) Influenza A virus subtype H5N1 together with B are shooters together with having their exam. Influenza A virus subtype H5N1 together with B autumn brusque 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 brusque of the qualifying mark, what is the qualifying mark?
Answer: 11
As Influenza A virus subtype H5N1 is brusque past times 10 - he has shot 1
As B is brusque past times 2 - he has shot 9
9+1=10 together with 10 < 11
9) In objective essay a right reply score four marks together with on a incorrect reply 2 marks. Influenza A virus subtype 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 therefore 130 is right answer.
10) An INK põrnikas starts jumping 1 meter to each management north, south, due east together with due west respectively. It marks a signal inwards the novel locations. It comes dorsum to its master signal after jumping inwards all directions. It in ane lawsuit again starts the same procedure from the newly drawn unique points. Totally how many points did the põrnikas mark?
11) Influenza A virus subtype H5N1 guy walks at 4kmph from a point. After 4hrs a cyclist starts from the same signal at 10kmph. At what distance volition they come across from the starting point?
Answer: 26.66km
Explanation: We have, s=vt where s=distance. Since both come across at same point, both travels same distance=s km. Now, equating, 10(t+4) = 4t ------> t=20/3
sub. t=20/3 inwards s=4t---------> s = 26.66km
12) What's the divergence betwixt COPY OF Influenza A virus subtype H5N1 FILE & MOVE_UPLOAD_FILE inwards file uploading?
Move: This part 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 go moved to the filename given past times destination.
If filename is non a valid upload file, therefore 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 make you lot insert unmarried & double quotes inwards MySQL db without using PHP?
& / "e;
Alternately, escape unmarried quote using forwards slash \' . In double quote you lot don't require to escape quotes. Insert double quotes every bit "".
14) What make you lot require to make to improve the performance (speedy execution) for the script you lot receive got written?
If your script is to call upwards information from Database, you lot should usage "Limit" syntax. Break downwardly the non dynamic sections of website which require non go repeated over a menses of fourth dimension every bit include files.
15) How make you lot capture audio/video inwards PHP?
You require 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 go compiled nether most operating systems, including Windows.
16) How make you lot know (status) whether the recipient of your post had opened the post i.e. read the mail?
Embed an URL inwards a say 0-byte picture tag may go the improve 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 rail whether your recipients receive got thought the emails or not.
17) What is random number?
A random position out is a position out generated past times a process, whose lawsuit is unpredictable, together with which cannot go sub sequentially reliably reproduced.
18) What is divergence betwixt srand & shuffle?
The srand part seeds the random position out generator alongside seed together with shuffle is used for shuffling the array values.
shuffle - This part shuffles (randomizes the lodge of the elements in) an array. This part assigns novel keys for the elements inwards array. It volition take whatever existing keys you lot may receive got assigned, rather than precisely reordering the keys.
srand - Seed the random position out generator
19) How tin nosotros take duplicate values from an array?
array_unique() funciton tin go used for the purpose.
20) How make I detect out conditions a position out is strange or even?
if (number%2==0 ) therefore fifty-fifty else odd.
21) How tin nosotros teach the ID generated from the previous insert operation?
SELECT MAX(ID) from tablename;
22) How to boundary the position out of rows to v that I go out of my database?
Select * from tablename LIMIT 0, 5;
23) How to shop binary information inwards MySQL?
Use BLOB information type for the database field.
24) How tin nosotros submit a shape without a submit button?
We tin submit a shape 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 divergence 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 kickoff unmarried matching tape of results.
mysql_fetch_row - fetches a final result row every bit array.
27) How to brand a download page inwards ain site, where I tin know that how many file has been loaded past times detail user or detail IP address?
We tin log the IP addresses inwards ane database tabular array piece downloading the file. This way nosotros tin count together with banking concern check the no. of rows inserted for a detail download.
28) What is divergence betwixt mysql_connect together with mysql_pconnect?
mysql_connect opens upwards a database connectedness every fourth dimension a page is loaded. mysql_pconnect opens upwards a connection, together with keeps it opened upwards across multiple requests.
mysql_pconnect uses less resources, because it does non require to constitute a database connectedness every fourth dimension a page is loaded.
29) What is the divergence 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 teach IP address?
getenv("REMOTE_ADDR");
31) How to brand a login page where in ane lawsuit the user has logged inwards volition become dorsum to the page it came from to login page?
32) How make nosotros know properties of the browser?
You tin get together a lot of information nigh a person's estimator past times using $_SERVER['HTTP_USER_AGENT']. This tin tell us to a greater extent than nigh the user's operating system, every bit good every bit their browser. For instance I am revealed to go 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 go useful to programmers if they are using especial features that may non piece of occupation for everyone, or if they desire to teach an thought of their target audience. This likewise is of import when using the get_browser() part for finding out to a greater extent than information nigh the browser's capabilities. By having this information the user tin go directed to a version of your site best suited to their browser.
get_browser() attempts to create upwards one's heed the capabilities of the user's browser. This is done past times looking upwards the browser's information inwards the browscap.ini file.
echo $_SERVER['HTTP_USER_AGENT'] . "<hr />\n";
$browser = get_browser();
foreach ($browser every bit $name => $value)
{
echo "<b>$name</b> $value <br />\n";
}
33) What is divergence betwixt require_once(), require(), include(). Because all these part are used to telephone telephone a file inwards around other file.
Difference betwixt require() together with require_once(): require() includes together with evaluates a specific file, piece require_once() does that entirely if it has non been included before (on the same page).
So, require_once() is recommended to usage 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 teach 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, piece include() entirely produces a WARNING.
There is likewise include_once() which is the same every bit include(), but the divergence betwixt them is the same every bit the divergence betwixt require() together with require_once().
34) If you lot receive got to piece of occupation alongside dates inwards the next format: "Tuesday, Feb 14, 2006 @ 10:39 am", how tin you lot convert them to around other format that is easier to use?
The strtotime part tin convert a string to a timestamp.
A timestamp tin go converted to engagement format. So it is best to shop the dates every bit timestamp inwards the database, together with precisely output them inwards 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 require to teach rid of the "@" sign, together with nosotros tin usage the remaining string every bit 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 thousand 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 upwards out forms, CAPTCHA programmers volition generate an picture containing distorted images of a string of numbers together with letters. Computers cannot create upwards one's heed what the numbers together with letters are from the picture but humans receive got slap-up pattern recognition abilities together with volition go able to fairly accurately create upwards one's heed the string of numbers together with letters. By entering the numbers together with letters from the picture inwards the validation field, the application tin go fairly assured that at that topographic point is a human customer using it.
36) What is the divergence betwixt sessions together with cookies?
37) What is the divergence betwixt $x together with $$x ?
$x is unproblematic variable. $$x is reference variable or infact a variable of variable. Influenza A virus subtype H5N1 variable variable allows us to alter the advert of a variable dynamically.
<?
$x = "this";
$$x = "is cake";
?>
The $$ is the syntax used inwards PHP for a variable variable. I tin straightaway telephone telephone the 2 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 every bit ${$x} inwards 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 business (\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 inwards 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 inwards shape submitting, give the instance where nosotros tin usage teach together with nosotros tin usage post methods?
43) What does PHP stands for together with who is the manly soul nurture of PHP? Explain the changes inwards PHP versions?
44) How tin nosotros create 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 go URL encoded together with tin go usage to append alongside URLs, usually used to append information for GET similar someurl.com?var=hello%world
string urldocode(str)
This volition unproblematic decode the GET variable’s value. Example: echo (urldecode($_GET_VARS[var])) volition output
“hello world”
46) What is the divergence betwixt the functions unlink together with unset?
unlink is a part for file organisation handling. It volition precisely delete the file inwards 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 dissimilar types of errors inwards PHP?
1. Notices: These are trivial, non-critical errors that PHP encounters piece executing a script - for example, accessing a variable that has non all the same been defined. By default, such errors are non displayed to the user at all - although you lot tin alter 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 make non final result inwards 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 campaign the immediate termination of the script, together with PHP’s default demeanour is to display them to the user when they receive got place.
48) How tin nosotros create a session variable & terminate it?
$_SESSION[’name’] = “Chinmay”;
To destroy a session: unset($_SESSION[’name’]);
49) How to Create a Cookie & destroy it inwards PHP?
setcookie(”variable”,”value”,”time”);
variable - advert 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 advert only
setcookie(”test”);
50) What is the divergence betwixt sizeof($array) together with count($array)?
sizeof($array) - This part is an alias of count()
count($array) - If you lot precisely top a unproblematic variable instead of an array it volition homecoming 1.
0 komentar:
Please comment if there are any that need to be asked.