Sei sulla pagina 1di 25

Advance Congratulation for your Interview

What's PHP The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. What Is a Session? A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor. essions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor. What is meant by PEA in !h!? Answer!" P#A$ is the next revolution in PHP. This repository is bringing higher level programming to PHP. P#A$ is a framewor% and distribution system for reusable PHP components. &t eases installation by bringing an automated wi'ard( and pac%ing the strength and experience of PHP users into a nicely organised ))P library. P#A$ also provides a command*line interface that can be used to automatically install +pac%ages+ Answer," P#A$ is short for +PHP #xtension and Application $epository+ and is pronounced just li%e the fruit. The purpose of P#A$ is to provide" A structured library of open*sourced code for PHP users A system for code distribution and pac%age maintenance A standard style for code written in PHP The PHP -oundation .lasses /P-.0( The PHP #xtension .ommunity 1ibrary /P#.10( A web site( mailing lists and download mirrors to support the PHP2P#A$ community P#A$ is a community*driven project with the P#A$ 3roup as the governing body. The project has been founded by tig . 4a%%en in !555 and quite a lot of people have joined the project since then. How can we "now the number of days between two given dates using PHP? imple arithmetic" 6date! 7 date/89*m*d80: 6date, 7 8,;;<*;=*;!8: 6days 7 /strtotime/0 * strtotime/00 2 /<; > <; > ,?0: echo +@umber of days since 8,;;<*;=*;!8" 6days+:

How can we re!air a #yS$% table? The syntex for repairing a mysql table is" $#PA&$ TA41# tablename $#PA&$ TA41# tablename AB&.C $#PA&$ TA41# tablename #DT#@D#D This command will repair the table specified. &f AB&.C is given( Ey A1 will do a repair of only the index tree. &f #DT#@D#D is given( it will create index row by row. What is the difference between &message and &&message? Anwser !" 6message is a simple variable whereas 66message is a reference variable. #xample"

http://facebook.com/adarshe

6user 7 8bob8 is equivalent to 6holder 7 8user8: 66holder 7 8bob8: Anwser ," They are both variables. 4ut 6message is a variable with a fixed name. 66message is a variable who8s name is stored in 6message. -or example( if 6message contains +var+( 66message is the same as 6var. What Is a Persistent Coo"ie? A persistent coo%ie is a coo%ie which is stored in a coo%ie file permanently on the browser8s computer. 4y default( coo%ies are created as temporary coo%ies which stored only in the browser8s memory. Fhen the browser is closed( temporary coo%ies will be erased. 9ou should decide when to use temporary coo%ies and when to use persistent coo%ies based on their differences"

Temporary coo%ies can not be used for trac%ing long*term information. Persistent coo%ies can be used for trac%ing long*term information. Temporary coo%ies are safer because no programs other than the browser can access them. Persistent coo%ies are less secure because users can open coo%ie files see the coo%ie values.

What does a s!ecial set of tags '?( and ?) do in PHP? The output is displayed directly to the browser. How do you define a constant? Gia define/0 directive( li%e define /+E9.)@ TA@T+( !;;0: How *o Write the +, # *ag Correctly for -!loading +iles? Fhen users clic%s the submit button( files specified in the H&@PBT T9P#7-&1#...I will be transferred from the browser to the Feb server. This transferring /uploading0 process is controlled by a properly written H-)$E...I tag as"

<FORM ACTION=receiving.php METHOD=post ENCTYPE=m !tip"rt#$orm% &"t"'


@ote that you must specify E#TH)D as +post+ and #@.T9P# as +multipart2form*data+ in order for the uploading process to wor%. The following PHP code( called logoJupload.php( shows you a complete -)$E tag for file uploading"

<(php print)*<htm!'<$orm "ction=processing+ p!o"&e&+$i!es.php* .* metho&=post enct,pe=m !tip"rt#$orm%&"t"'-n*./ print)*P!e"se s 0mit "n im"ge $i!e " 1e0 site !ogo $or* .* $,icenter.com2<0r'-n*./ print)*<inp t t,pe=$i!e n"me=$,icenter+!ogo'<0r'-n*./ print)*<inp t t,pe=s 0mit'-n*./ print)*<#$orm'<#htm!'-n*./ ('
What are the differences between re.uire and include/ include0once? Anwser !" requireJonce/0 and includeJonce/0 are both the functions to include and evaluate the specified file only

http://facebook.com/adarshe

once. &f the specified file is included previous to the present call occurrence( it will not be done again. 4ut require/0 and include/0 will do it as many times they are as%ed to do. Anwser ," The includeJonce/0 statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include/0 statement( with the only difference being that if the code from a file has already been included( it will not be included again. The major difference between include/0 and require/0 is that in failure include/0 produces a warning message whereas require/0 produces a fatal errors. Anwser K" All three are used to an include file into the current page. &f the file is not present( require/0( calls a fatal error( while in include/0 does not. The includeJonce/0 statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include/0 statement( with the only difference being that if the code from a file has already been included( it will not be included again. &t des not call a fatal error if file not exists. requireJonce/0 does the same as includeJonce/0( but it calls a fatal error if file not exists. Anwser ?" -ile will not be included more than once. &f we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function includeJonce/0. This will prevent problems with function redefinitions( variable value reassignments( etc. What is meant by urlencode and urldecode? Anwser !" urlencode/0 returns the B$1 encoded version of the given string. B$1 coding converts special characters into L signs followed by two hex digits. -or example" urlencode/+!;.;;L+0 will return +!;L,#;;L,M+. B$1 encoded strings are safe to be used as part of B$1s. urldecode/0 returns the B$1 decoded version of the given string. Anwser ," string urlencode/str0 * $eturns the B$1 encoded version of the input string. tring values to be used in B$1 query string need to be B$1 encoded. &n the B$1 encoded version" Alphanumeric characters are maintained as is. pace characters are converted to +N+ characters. )ther non*alphanumeric characters are converted +L+ followed by two hex digits representing the converted character. string urldecode/str0 * $eturns the original string of the input B$1 encoded string. -or example" 6discount 7+!;.;;L+: 6url 7 +http"22domain.com2submit.phpOdisc7+.urlencode/6discount0: echo 6url: 9ou will get +http"22domain.com2submit.phpOdisc7!;L,#;;L,M+. How *o 1et the -!loaded +ile Information in the eceiving Scri!t? )nce the Feb server received the uploaded file( it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called 6J-&1# . Bploaded file information is organi'ed in 6J-&1# as a two*dimensional array as"

6J-&1# P6field@ameQP8name8Q * The )riginal file name on the browser system. 6J-&1# P6field@ameQP8type8Q * The file type determined by the browser. 6J-&1# P6field@ameQP8si'e8Q * The @umber of bytes of the file content. 6J-&1# P6field@ameQP8tmpJname8Q * The temporary filename of the file in which the uploaded file was stored on the server.

http://facebook.com/adarshe

6J-&1# P6field@ameQP8error8Q * The error code associated with this file upload.

The 6field@ame is the name used in the H&@PBT T9P#7-&1#( @AE#7field@ameI. What is the difference between mys.l0fetch0ob2ect and mys.l0fetch0array? Ey A1 fetch object will collect first single matching record where mysqlJfetchJarray will collect all matching records from the table in an array How can I e3ecute a PHP scri!t using command line? Rust run the PHP .1& /.ommand 1ine &nterface0 program and provide the PHP script file name as the command line argument. -or example( +php my cript.php+( assuming +php+ is the command to invo%e the .1& program. 4e aware that if your PHP script was written for the Feb .3& interface( it may not execute properly in command line environment. I am trying to assign a variable the value of 4567/ but it "ee!s coming u! with a different number/ what8s the !roblem? PHP &nterpreter treats numbers beginning with ; as octal. 1oo% at the similar PHP interview questions for more numeric problems. Would I use !rint 9&a dollars9 or 9:&a; dollars9 to !rint out the amount of dollars in this e3am!le? &n this example it wouldnSt matter( since the variable is all by itself( but if you were to print something li%e +T6aU(;;;(;;; mln dollars+( then you definitely need to use the braces. What are the different tables !resent in #yS$%? Which ty!e of table is generated when we are creating a table in the following synta3< create table em!loyee=eno int=6>/ename varchar=54>>? Total M types of tables we can create !. Ey& AE ,. Heap K. Eerge ?. &@@) D4 M. & AE Ey& AE is the default storage engine as of Ey A1 K.,K. Fhen you fire the above create query Ey A1 will create a Ey& AE table. How *o Create a *able? &f you want to create a table( you can run the .$#AT# TA41# statement as shown in the following sample script" HOphp include +mysqlJconnection.php+: 6sql 7 +.$#AT# TA41# fyiJlin%s /+ . + id &@T#3#$ @)T @B11+ . +( url GA$.HA$/V;0 @)T @B11+ . +( notes GA$.HA$/!;,?0+ . +( counts &@T#3#$+ . +( time T&E# TAEP D#-AB1T sysdate/0+ . +0+: if /mysqlJquery/6sql( 6con00 T print/+Table fyiJlin%s created.Wn+0: U else T print/+Table creation failed.Wn+0: U mysqlJclose/6con0:

http://facebook.com/adarshe

OI $emember that mysqlJquery/0 returns T$B#2-A1 # on .$#AT# statements. &f you run this script( you will get something li%e this" Table fyiJlin%s created. How can we encry!t the username and !assword using PHP? Answer! 9ou can encrypt a password with the following EysqlI #T PA F)$D7PA

F)$D/+Password+0:

Answer, 9ou can use the Ey A1 PA F)$D/0 function to encrypt username and password. -or example( &@ #$T into user /password( ...0 GA1B# /PA F)$D/6passwordX00( ...0: How do you !ass a variable by value? Rust li%e in .NN( put an ampersand in front of it( li%e 6a 7 Y6b WHA* IS *HE +-?C*I,?A%I*@ ,+ *HE +-?C*I,?S S* S* => A?A S* IS* =>? string strstr / string haystac%( string needle 0 returns part of haystac% string from the first occurrence of needle to the end of haystac%. This function is case*sensitive. stristr/0 is idential to strstr/0 except that it is case insensitive. When are you su!!osed to use endif to end the conditional statement? Fhen the original if was followed by " and then the code bloc% without braces. How can we send mail using BavaScri!t? @o. There is no way to send emails directly using Rava cript. 4ut you can use Rava cript to execute a client side email program send the email using the +mailto+ code. Here is an example" function myfunction/form0 T tdata7document.myform.tbox!.value: location7+mailto"mailidZdomain.comOsubject7...+: return true: U What is the functionality of the function strstr and stristr? strstr/0 returns part of a given string from the first occurrence of a given substring to the end of the string. -or example" strstr/+userZexample.com+(+Z+0 will return +Zexample.com+. stristr/0 is idential to strstr/0 except that it is case insensitive. What is the difference between ereg0re!lace=> and eregi0re!lace=>? eregiJreplace/0 function is identical to eregJreplace/0 except that it ignores case distinction when matching alphabetic characters. How do I find out the number of !arameters !assed into functionCD ? funcJnumJargs/0 function returns the number of parameters passed in. What is the !ur!ose of the following files having e3tensions< frm/ myd/ and myi? What these files contain?

http://facebook.com/adarshe

&n Ey A1( the default table type is Ey& AE. #ach Ey& AE table is stored on dis% in three files. The files have names that begin with the table name and have an extension to indicate the file type. The 8.frm8 file stores the table definition. The data file has a 8.E9D8 /E9Data0 extension. The index file has a 8.E9&8 /E9&ndex0 extension( If the variable &a is e.ual to E and variable &b is e.ual to character a/ what8s the value of &&b? !;;( itSs a reference to existing variable. Write a .uery for the following .uestion The table tblJsites contains the following data" ***************************************************** Bserid sitename country ****************************************************** ! sureshbabu indian , PHPprogrammer andhra K PHP.net usa ? PHPtal%.com germany M Ey A1.com usa < sureshbabu canada = PHPbuddy.com pa%istan V. PHPtal%.com austria 5. PHPfrea%s.com sourthafrica !;. PHPsupport.net russia !!. sureshbabu australia !,. sureshbabu nepal !K. PHPtal%.com italy Frite a select query that will be displayed the duplicated site name and how many times it is duplicatedO [ #1#.T sitename( .)B@T/>0 A @um)ccurrences -$)E tblJsites 3$)BP 49 sitename HAG&@3 .)B@T/>0 I ! How *o Protect S!ecial Characters in $uery String? &f you want to include special characters li%e spaces in the query string( you need to protect them by applying the urlencode/0 translation function. The script below shows how to use urlencode/0" HOphp print/+HhtmlI+0: print/+HpIPlease clic% the lin%s below+ .+ to submit comments about -9&.enter.com"H2pI+0: 6comment 7 8& want to say" +&tW8s a good site\ "*I+8: 6comment 7 urlencode/6comment0: print/+HpI+ .+Ha href7W+processingJforms.phpOname73uestYcomment76commentW+I+ .+&t8s an excellent site\H2aIH2pI+0: 6comment 7 8This visitor said" +&tW8s an average site\ "*/+8: 6comment 7 urlencode/6comment0: print/+HpI+ .8Ha href7+processingJforms.phpO8.6comment.8+I8 .+&t8s an average site.H2aIH2pI+0: print/+H2htmlI+0: OI Are ob2ects !assed by value or by reference?

http://facebook.com/adarshe

#verything is passed by value. What are the differences between A ,P a table and * -?CA*E a table? D$)P TA41# tableJname * This will delete the table and its data. T$B@.AT# TA41# tableJname * This will delete the data of the table( but not the table definition. What are the differences between 1E* and P,S* methods in form submitting/ give the case where we can use 1E* and we can use P,S* methods? Anwser !" Fhen we submit a form( which has the 3#T method it displays pair of name2value used in the form at the address bar of the browser preceded by url. Post method doesn8t display these values. Anwser ," Fhen you want to send short or small data( not containing A .&& characters( then you can use 3#TX Eethod. 4ut for long data sending( say more then !;; character you can use P) T method. )nce most important difference is when you are sending the form with 3#T method. 9ou can see the output which you are sending in the address bar. Fhereas if you send the form with P) TX method then user can not see that information. Anwser K" Fhat are +3#T+ and +P) T+O 3#T and P) T are methods used to send data to the server" Fith the 3#T method( the browser appends the data onto the B$1. Fith the Post method( the data is sent as +standard input.+ Eajor Difference &n simple words( in P) T method data is sent by standard input /nothing shown in B$1 when posting while in 3#T method data is sent through query string. #x" Assume we are logging in with username and password. 3#T" we are submitting a form to login.php( when we do submit or similar action( values are sent through visible query string /notice .2login.phpOusername7...Ypassword7... as B$1 when executing the script login.php0 and is retrieved by login.php by 6J3#TP8username8Q and 6J3#TP8password8Q. P) T" we are submitting a form to login.php( when we do submit or similar action( values are sent through invisible standard input /notice .2login.php0 and is retrieved by login.php by 6JP) TP8username8Q and 6JP) TP8password8Q. P) T is assumed more secure and we can send lot more data than that of 3#T method is limited /they say &nternet #xplorer can ta%e care of maximum ,;VK character as a query string0. Anwser ?" &n the get method the data made available to the action page / where data is received 0 by the B$1 so data can be seen in the address bar. @ot advisable if you are sending login info li%e password etc. &n the post method the data will be available as data bloc%s and not as query string in case of get method. Anwser M" Fhen we submit a form( which has the 3#T method it pass value in the form of query string /set of name2value pair0 and display along with B$1. Fith 3#T we can a small data submit from the form /a set of ,MM character0 whereas Post method doesn8t display value with B$1. &t passes value in the form of )bject and we can submit large data from the form.

http://facebook.com/adarshe

Anwser <" )n the server side( the main difference between 3#T and P) T is where the submitted is stored. The 6J3#T array stores data submitted by the 3#T method. The 6JP) T array stores data submitted by the P) T method. )n the browser side( the difference is that data submitted by the 3#T method will be displayed in the browserSs address field. Data submitted by the P) T method will not be displayed anywhere on the browser. 3#T method is mostly used for submitting a small amount and less sensitive data. P) T method is mostly used for submitting a large amount or sensitive data. How do you call a constructor for a !arent class? parent""constructor/6value0 WHA* A E *HE AI++E E?* *@PES ,+ E , S I? PHP? Here are three basic types of runtime errors in PHP" !. @otices" These are trivial( non*critical errors that PHP encounters while executing a script * for example( accessing a variable that has not yet been defined. 4y default( such errors are not displayed to the user at all * although you can change this default behavior. ,. Farnings" These are more serious errors * for example( attempting to include/0 a file which does not exist. 4y default( these errors are displayed to the user( but they do not result in script termination. K. -atal 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 PHP8s default behavior is to display them to the user when they ta%e place. &nternally( these variations are represented by twelve different error types What8s the s!ecial meaning of 00slee! and 00wa"eu!? JJsleep returns the array of all the variables than need to be saved( while JJwa%eup retrieves them. How can we submit a form without a submit button? &f you don8t want to use the ubmit button to submit a form( you can use normal hyper lin%s to submit a form. 4ut you need to use some Rava cript code in the B$1 of the lin%. -or example" Ha href7+javascript" document.myform.submit/0:+I ubmit EeH2aI Why doesn8t the following code !rint the newline !ro!erly? '?!h! &str ( FHello/ thereDGnHow are you?Gn*han"s for visiting fyicenter8H !rint &strH ?) 4ecause inside the single quotes the Wn character is not interpreted as newline( just as a sequence of two characters * W and n. Would you initialiIe your strings with single .uotes or double .uotes? ince the data inside the single*quoted string is not parsed for variable substitution( itSs always a better idea speed*wise to initiali'e a string with single quotes( unless you specifically need variable substitution. How can we e3tract string 'abcDcom ' from a string htt!<JJinfoKabcDcom using regular e3!ression of !h!?

We can use the preg_match() function with "/.*@(.*)$/" as the regular expression pattern. For example: preg_match("/.*@(.*)$/" "http://info@a!c.com" $"ata)# echo $"ata$%&#

http://facebook.com/adarshe

What is the difference between the functions unlin" and unset? unlin%/0 is a function for file system handling. &t will simply delete the file in context. unset/0 is a function for variable management. &t will ma%e a variable undefined. How come the code wor"s/ but doesn8t for twoLdimensional array of mine? Any time you have an array with more than one dimension( complex parsing syntax is required. print +.ontents" T6arrP!QP,QU+ wouldSve wor%ed. How can we register the variables into a session? sessionJregister/6sessionJvar0: 6J # &)@P8var8Q 7 8value8:

What is the difference between characters G467 and G367? The first one is octal ,K( the second is hex ,K. With a heredoc synta3/ do I get variable substitution inside the heredoc contents? 9es. How can we submit form without a submit button? Fe can use a simple Rava cript code lin%ed to an event trigger of any form field. &n the Rava cript code( we can call the document.form.submit/0 function to submit the form. -or example" Hinput type7button value7+ ave+ on.lic%7+document.form.submit/0+I How can we create a database using PHP and mys.l? Fe can create Ey A1 database with the use of mysqlJcreateJdb/6database@ame0 to create a database. How many ways we can retrieve the date in result set of mys.l using !h!? As individual objects so single record or as a set or arrays. Can we use include =9abcD!h!9> two times in a !h! !age 9ma"eitD!h!9? 9es. +or !rinting out strings/ there are echo/ !rint and !rintfD E3!lain the differencesD echo is the most primitive of them( and just outputs the contents following the construct to the screen. print is also a construct /so parentheses are optional when calling it0( but it returns T$B# on successful output and -A1 # if it was unable to print out the string. However( you can pass multiple parameters to echo( li%e" HOphp echo 8Felcome 8( 8to8( 8 8( 8fyicenter\8: OI and it will output the string +Felcome to fyicenter\+ print does not ta%e multiple parameters. &t is also generally argued that echo is faster( but usually the speed advantage is negligible( and might not be there for future versions of PHP. printf is a function( not a construct( and allows such advantages as formatted output( but itSs the slowest way to print out data out of echo( print and printf. I am writing an a!!lication in PHP that out!uts a !rintable version of driving directionsD It contains some long sentences/ and I am a neat frea"/ and would li"e to ma"e sure that no line e3ceeds E4 charactersD How do I accom!lish that with PHP?

http://facebook.com/adarshe

)n large strings that need to be formatted according to some length specifications( use wordwrap/0 or chun%Jsplit/0. What8s the out!ut of the ucwords function in this e3am!le? 6formatted 7 ucwords/+-9&.#@T#$ & .)11#.T&)@ )- &@T#$G&#F AB# T&)@ +0: print 6formatted: Fhat will be printed is -9&.#@T#$ & .)11#.T&)@ )- &@T#$G&#F AB# T&)@ . ucwords/0 ma%es every first letter of every word capital( but it does not lower*case anything else. To avoid this( and get a properly formatted string( itSs worth using strtolower/0 first. What8s the difference between htmlentities=> and htmls!ecialchars=>? htmlspecialchars only ta%es care of H( I( single quote ]( double quote + and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTE1. How can we e3tract string 9abcDcom9 from a string 9mailto<infoKabcDcom?sub2ect(+eedbac"9 using regular e3!ression of PHP? 6text 7 +mailto"infoZabc.comOsubject7-eedbac%+: pregJmatch/8^.>Z/P_OQ>0^8( 6text( 6output0: echo 6outputP!Q: @ote that the second index of 6output( 6outputP!Q( gives the match( not the first one( 6outputP;Q. So if mdE=> generates the most secure hash/ why would you ever use the less secure crc76=> and sha5=>? .rypto usage in PHP is simple( but that doesnSt mean itSs free. -irst off( depending on the data that youSre encrypting( you might have reasons to store a K,*bit value in the database instead of the !<;*bit value to save on space. econd( the more secure the crypto is( the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down( if frequent mdM/0 generation is required. How can we destroy the session/ how can we unset the variable of a session? sessionJunregister/0 * Bnregister a global variable from the current session sessionJunset/0 * -ree all session variables What are the different functions in sorting an array? orting functions in PHP" asort/0 arsort/0 %sort/0 %rsort/0 u%sort/0 sort/0 natsort/0 rsort/0 How can we "now the countJnumber of elements of an array? , ways" a0 si'eof/6array0 * This function is an alias of count/0 b0 count/6urarray0 * This function returns the number of elements in an array. &nterestingly if you just pass a simple var instead of an array( count/0 will return !. How many ways we can !ass the variable through the navigation between the !ages? At least K ways" !. Put the variable into session in the first page( and get it bac% from session in the next page.

http://facebook.com/adarshe

,. Put the variable into coo%ie in the first page( and get it bac% from the coo%ie in the next page. K. Put the variable into a hidden form field( and get it bac% from the form in the next page. What is the ma3imum length of a table name/ a database name/ or a field name in #yS$%? Database name" <? characters Table name" <? characters .olumn name" <? characters How many values can the SE* function of #yS$% ta"e? Ey A1 #T function can ta%e 'ero or more values( but at the maximum it can ta%e <? values. What are the other commands to "now the structure of a table using #yS$% commands e3ce!t EMP%AI? command? D# .$&4# tableJname: How can we find the number of rows in a table using #yS$%? Bse this for Ey A1 #1#.T .)B@T/>0 -$)E tableJname: What8s the difference between mdE=>/ crc76=> and sha5=> cry!to on PHP? The major difference is the length of the hash generated. .$.K, is( evidently( K, bits( while sha!/0 returns a !,V bit value( and mdM/0 returns a !<; bit value. This is important when avoiding collisions. How can we find the number of rows in a result set using PHP? Here is how can you find the number of rows in a result set in PHP" 6result 7 mysqlJquery/6anyJvalidJsql( 6databaseJlin%0: 6numJrows 7 mysqlJnumJrows/6result0: echo +6numJrows rows found+: How many ways we can we find the current date using #yS$%? #1#.T .B$DAT#/0: #1#.T .B$$#@TJDAT#/0: #1#.T .B$T&E#/0: #1#.T .B$$#@TJT&E#/0: 1ive the synta3 of 1 A?* commands? The generic syntax for 3$A@T is as following 3$A@T PrightsQ on PdatabaseQ T) PusernameZhostnameQ &D#@T&-&#D 49 PpasswordQ @ow rights can be" a0 A11 privilages b0 .ombination of .$#AT#( D$)P( #1#.T( &@ #$T( BPDAT# and D#1#T# etc. Fe can grant rights on all databse by usingh >.> or some specific database by database.> or a specific table by database.tableJname.

1ive the synta3 of EN,OE commands? The generic syntax for revo%e is as following

http://facebook.com/adarshe

$#G)C# PrightsQ on PdatabaseQ -$)E PusernameZhostnameQ @ow rights can be" a0 A11 privilages b0 .ombination of .$#AT#( D$)P( #1#.T( &@ #$T( BPDAT# and D#1#T# etc. Fe can grant rights on all databse by usingh >.> or some specific database by database.> or a specific table by database.tableJname. Answer the .uestions with the following assum!tion The structure of table view buyers is as follows"

'((((((((((((('((((((((((((('(((((('((((('((((((((( '((((((((((((((((' ) Fiel" ) *+pe ) ,ull ) -e+ ) .efault ) /xtra ) '((((((((((((('((((((((((((('(((((('((((('((((((((( '((((((((((((((((' ) user_pri_i" ) int(%0) ) ) 123 ) ,455 ) auto_increment ) ) useri" ) 6archar(%7) ) 8/9 ) ) ,455 ) ) '((((((((((((('((((((((((((('(((((('((((('((((((((( '(((((((((((((((('
The value of userJpriJid of the last row is ,K?M. Fhat will happen in the following conditionsO .ondition !" Delete all the rows and insert another row. Fhat is the starting value for this auto incremented field userJpriJidO .ondition ," Delete the last row /having the field value ,K?M0 and insert another row. Fhat is the value for this auto incremented field userJpriJidO &n both conditions( the value of this auto incremented field userJpriJid is ,K?<. What is the difference between CHA and NA CHA data ty!es? .HA$ is a fixed length data type. .HA$/n0 will ta%e n characters of storage even if you enter less than n characters to that column. -or example( +Hello\+ will be stored as +Hello\ + in .HA$/!;0 column. GA$.HA$ is a variable length data type. GA$.HA$/n0 will ta%e only the required storage for the actual number of characters entered to that column. -or example( +Hello\+ will be stored as +Hello\+ in GA$.HA$/!;0 column. How can we encry!t and decry!t a data !resent in a mys.l table using mys.l? A# J#@.$9PT/0 and A# JD#.$9PT/0 Will com!arison of string 9549 and integer 55 wor" in PHP? 9es( internally PHP will cast everything to the integer type( so numbers !; and !! will be compared. What is the functionality of #AE function in PHP? string mdM/string0 &t calculates the EDM hash of a string. The hash is a K,*character hexadecimal number. How can I load data from a te3t file into a table? The Ey A1 provides a 1)AD DATA &@-&1# command. 9ou can load data from a file. 3reat tool but you need to ma%e sure that" a0 Data must be delimited b0 Data fields must match table columns correctly

http://facebook.com/adarshe

How can we "now the number of days between two given dates using #yS$%? Bse DAT#D&--/0 #1#.T DAT#D&--/@)F/0(8,;;<*;=*;!80: How can we change the name of a column of a table? This will change the name of column" A1T#$ TA41# tableJname .HA@3# oldJcolmJname newJcolmJname How can we change the data ty!e of a column of a table? This will change the data type of a column" A1T#$ TA41# tableJname .HA@3# colmJname sameJcolmJname Pnew data typeQ What is the difference between 1 ,-P P@ and , AE P@ in S$%? To sort a result( use an )$D#$ 49 clause. The most general way to satisfy a 3$)BP 49 clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive( and then use this temporary table to discover groups and apply aggregate functions /if any0. )$D#$ 49 Pcol!Q(Pcol,Q(...PcolnQ: Tells D4E according to what columns it should sort the result. &f two rows will hawe the same value in col! it will try to sort them according to col, and so on. 3$)BP 49 Pcol!Q(Pcol,Q(...PcolnQ: Tells D4E to group /aggregate0 results with same value of column col!. 9ou can use .)B@T/col!0( BE/col!0( AG3/col!0 with it( if you want to count all items in group( sum all values or view average. What is meant by #I#E? Answer !" E&E# is Eultipurpose &nternet Eail #xtensions is an &nternet standard for the format of e*mail. However browsers also uses E&E# standard to transmit files. E&E# has a header which is added to a beginning of the data. Fhen browser sees such header it shows the data as it would be a file /for example image0 ome examples of E&E# types" audio2x*ms*wmp image2png aplication2x*shoc%wave*flash Answer ," Eultipurpose &nternet Eail #xtensions. FFF8s ability to recogni'e and handle files of different types is largely dependent on the use of the E&E# /Eultipurpose &nternet Eail #xtensions0 standard. The standard provides for a system of registration of file types with information about the applications needed to process them. This information is incorporated into Feb server and browser software( and enables the automatic recognition and display of registered file types. [ How can we "now that a session is started or not? A session starts by sessionJstart/0 function. This sessionJstart/0 is always declared in header portion. it always declares first. then we write sessionJregister/0. What are the differences between mys.l0fetch0array=>/ mys.l0fetch0ob2ect=>/ mys.l0fetch0row=>? Answer !" mysqlJfetchJarray/0 *I -etch a result row as a combination of associative array and regular array. mysqlJfetchJobject/0 *I -etch a result row as an object.

http://facebook.com/adarshe

mysqlJfetchJrow/0 *I -etch a result set as a regular array/0. Answer ," The difference between mysqlJfetchJrow/0 and mysqlJfetchJarray/0 is that the first returns the results in a numeric array /6rowP;Q( 6rowP!Q( etc.0( while the latter returns a the results an array containing both numeric and associative %eys /6rowP8name8Q( 6rowP8email8Q( etc.0. mysqlJfetchJobject/0 returns an object /6row*Iname( 6row*Iemail( etc.0. If we login more than one browser windows at the same time with same user and after that we close one window/ then is the session is e3ist to other windows or not? And if yes then why? If no then why? ession depends on browser. &f browser is closed then session is lost. The session data will be deleted after session time out. &f connection is lost and you recreate connection( then session will continue in the browser. What are the #yS$% database files stored in system ? Data is stored in name.myd Table structure is stored in name.frm &ndex is stored in name.myi What is the difference between PHPQ and PHPE? PHP? cannot support oops concepts and `end engine ! is used. PHPM supports oops concepts and `end engine , is used. #rror supporting is increased in PHPM. DE1 and A11ite will is increased in PHPM. Can we use include=abcDPHP> two times in a PHP !age ma"eitDPHPR? 9es we can include that many times we want( but here are some things to ma%e sure of" /including abc.PHP( the file names are case*sensitive0 there shouldn8t be any duplicate function names( means there should not be functions or classes or variables with the same name in abc.PHP and ma%eit.php What are the differences between mys.l0fetch0array=>/ mys.l0fetch0ob2ect=>/ mys.l0fetch0row=>? mysqlJfetchJarray * -etch a result row as an associative array and a numeric array. mysqlJfetchJobject * $eturns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. $eturns an object with properties that correspond to the fetched row( or -A1 # if there are no more rows mysqlJfetchJrow/0 * -etches one row of data from the result associated with the specified result identifier. The row is returned as an array. #ach result column is stored in an array offset( starting at offset ;. What is meant by nl6br=>? Anwser!" nl,br/0 inserts a HTE1 tag HbrI before all new line characters Wn in a string. echo nl,br/+god bless Wn you+0: output" god blessHbrI you How can we encry!t and decry!t a data !resented in a table using #yS$%?

http://facebook.com/adarshe

9ou can use functions" A# J#@.$9PT/0 and A# JD#.$9PT/0 li%e" A# J#@.$9PT/str( %eyJstr0 A# JD#.$9PT/cryptJstr( %eyJstr0 How can I retrieve values from one database server and store them in other database server using PHP? -or this purpose( you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database. WH, IS *HE +A*HE ,+ PHP A?A WHA* IS *HE C$asmus 1erdorf. PHP M.!. 4eta Ey A1 M.; E?* NE SI,? ,+ PHP A?A #@S$%?

I? H,W #A?@ WA@S WE CA? E* IENE AA*A I? *HE ES-%* SE* ,+ #@S$% -SI?1 PHP? mysqlJfetchJarray * -etch a result row as an associative array( a numeric array( or both mysqlJfetchJassoc * -etch a result row as an associative array mysqlJfetchJobject * -etch a result row as an object mysqlJfetchJrow a* 3et a result row as an enumerated array What are the functions for I#AP? imapJbody * $ead the message body imapJchec% * .hec% current mailbox imapJdelete * Ear% a message for deletion from current mailbox imapJmail * end an email message What are encry!tion functions in PHP? .$9PT/0 EDM/0 What is the difference between htmlentities=> and htmls!ecialchars=>? htmlspecialchars/0 * .onvert some special characters to HTE1 entities /)nly the most widely used0 htmlentities/0 * .onvert A11 special characters to HTE1 entities What is the functionality of the function htmlentities? htmlentities/0 * .onvert all applicable characters to HTE1 entities This function is identical to htmlspecialchars/0 in all ways( except with htmlentities/0( all characters which have HTE1 character entity equivalents are translated into these entities. How can we get the !ro!erties =siIe/ ty!e/ width/ height> of an image using !h! image functions? To %now the image si'e use getimagesi'e/0 function To %now the image width use imagesx/0 function To %now the image height use imagesy/0 function How can we increase the e3ecution time of a !h! scri!t? 4y the use of void setJtimeJlimit/int seconds0 et the number of seconds a script is allowed to run. &f this is reached( the script returns a fatal error. The default limit is K; seconds or( if it exists( the maxJexecutionJtime value defined in the php.ini. &f seconds is set to 'ero( no time limit is imposed. Fhen called( setJtimeJlimit/0 restarts the timeout counter from 'ero. &n other words( if the timeout is the default K; seconds( and ,M seconds into script execution a call such as setJtimeJlimit/,;0 is made( the script will run for a total of ?M seconds before timing out.

http://facebook.com/adarshe

H,W CA? WE *AOE A PACO-P ,+ A #@S$% *AP%E A?A H,W CA? WE ES*, E I*? Answer !" .reate a full bac%up of your database" shellI mysqldump tab72path2to2some2dir opt dbJname )r" shellI mysqlhotcopy dbJname 2path2to2some2dir The full bac%up file is just a set of A1 statements( so restoring it is very easy" shellI mysql +.+#xecuted+: Answer ," To bac%up" 4A.CBP TA41# tblJname T) 2path2to2bac%up2directory S To restore" $# T)$# TA41# tblJname -$)E 2path2to2bac%up2directory mysqldump" Dumping Table tructure and Data Btility to dump a database or a collection of database for bac%up or for transferring the data to another A1 server /not necessarily a Ey A1 server0. The dump will contain A1 statements to create the table and2or populate the table. *t( no*create*info Don8t write table creation information /the .$#AT# TA41# statement0. *d( no*data Don8t write any row information for the table. This is very useful if you just want to get a dump of the structure for a table\ How to set coo"ies? setcoo%ie/8variable8(8value8(8time80 : variable * name of the coo%ie variable value * value of the coo%ie variable time * expiry time #xample" setcoo%ie/8Test8(6i(time/0NK<;;0: Test * coo%ie variable name 6i * value of the variable 8Test8 time/0NK<;; * denotes that the coo%ie will expire after an one hour How to resetJdestroy a coo"ie $eset a coo%ie by specifying expire time in the past" #xample" setcoo%ie/8Test8(6i(time/0*K<;;0: 22 already expired time $eset a coo%ie by specifying its name only #xample" setcoo%ie/8Test80: WHA* *@PES ,+ I#A1ES *HA* PHP S-PP, *S? Bsing imagetypes/0 function to find out what types of images are supported in your PHP engine. imagetypes/0 * $eturns the image types supported. This function returns a bit*field corresponding to the image formats supported by the version of 3D lin%ed into PHP. The following bits are returned( &E3J3&- ^ &E3JRP3 ^ &E3JP@3 ^ &E3JF4EP ^ &E3JDPE. CHECO I+ A NA IAP%E IS A? I?*E1E I? BANASC IP* var myGalue 75.V: if/parse&nt/myGalue077 myGalue0 alert/8&nteger80: else alert/8@ot an integer80:

http://facebook.com/adarshe

*ools used for drawing E diagramsD .ase tudio mart Draw How can I "now that a variable is a number or not using a BavaScri!t? Answer !" bool isJnumeric/ mixed var0 $eturns T$B# if var is a number or a numeric string( -A1 # otherwise. Answer ," Definition and Bsage The is@a@/0 function is used to chec% if a value is not a number. yntax is@a@/number0 Parameter Description number $equired. The value to be tested How can we submit from without a submit button? Trigger the Rava cript code on any event / li%e on elect of drop down list box( onfocus( etc 0 document.myform.submit/0: This will submit the form. How many ways can we get the value of current session id? sessionJid/0 returns the session id for the current session. How can we destroy the coo"ie? et the coo%ie with a past expiration time. What are the current versions of A!ache/ PHP/ and #yS$%? PHP" PHP M.!., Ey A1" Ey A1 M.! Apache" Apache ,.! What are the reasons for selecting %A#P =%inu3/ A!ache/ #yS$%/ Ph!> instead of combination of other software !rograms/ servers and o!erating systems? All of those are open source resource. ecurity of linux is very very more than windows. Apache is a better server that && both in functionality and security. Eysql is world most popular open source database. Php is more faster that asp or any other scripting language. What are the features and advantages of ,PBEC* , IE?*EA P ,1 A##I?1? )ne of the main advantages of )) programming is its ease of modification: objects can easily be modified and added to a system there by reducing maintenance costs. )) programming is also considered to be better at modeling the real world than is procedural programming. &t allows for more complicated and flexible interactions. )) systems are also easier for non*technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. -or some systems( an )) approach can speed development time since many objects are standard across systems and can be reused. .omponents that manage dates( shipping( shopping carts( etc. can be purchased and easily modified for a specific system. What is the use of friend function?

http://facebook.com/adarshe

-riend functions ometimes a function is best shared among a number of different classes. uch functions can be declared either as member functions of one class or as global functions. &n either case they can be set to be friends of other classes( by using a friend specifier in the class that is admitting them. uch functions can use all attributes of the class which names them as a friend( as if they were themselves members of that class. A friend declaration is essentially a prototype for a member function( but instead of requiring an implementation with the name of that class attached by the double colon syntax( a global function or member function of another class provides the match. class mylin%age T private" mylin%age > prev: mylin%age > next: protected" friend void setJprev/mylin%age> 1( mylin%age> @0: void setJnext/mylin%age> 10: public" mylin%age > succ/0: mylin%age > pred/0: mylin%age/0: U: void mylin%age""setJnext/mylin%age> 10 T next 7 1: U void setJprev/mylin%age > 1( mylin%age > @ 0 T @*Iprev 7 1: U -riends in other classes &t is possible to specify a member function of another class as a friend as follows" class . T friend int 4""f!/0: U: class 4 T int f!/0: U: &t is also possible to specify all the functions in another class as friends( by specifying the entire class as a friend. class A T friend class 4: U: -riend functions allow binary operators to be defined which combine private data in a pair of objects. This is particularly powerful when using the operator overloading features of .NN. Fe will return to it when we loo% at overloading. How can we get second of the current time using date function? 6second 7 date/+s+0: What is the ma3imum siIe of a file that can be u!loaded using PHP and how can we change this? 9ou can change maximum si'e of a file set uploadJmaxJfilesi'e variable in php.ini file How can I ma"e a scri!t that can be bilingual =su!!orts English/ 1erman>? 9ou can change charset variable in above line in the script to support bilanguage.

http://facebook.com/adarshe

What are the difference between abstract class and interface? Abstract class" abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods( which are declare in its class but not define. The definition of those methods must be in its extending class. &nterface" &nterfaces are one type of class where all the methods are abstract. That means all the methods only declared but not defined. All the methods must be define by its implemented class. What are the advantages of stored !rocedures/ triggers/ inde3es? A stored procedure is a set of A1 commands that can be compiled and stored in the server. )nce this has been done( clients don8t need to %eep re*issuing the entire query but can refer to the stored procedure. This provides better overall performance because the query has to be parsed only once( and less information needs to be sent between the server and the client. 9ou can also raise the conceptual level by having libraries of functions in the server. However( stored procedures of course do increase the load on the database server system( as more of the wor% is done on the server side and less on the client /application0 side. Triggers will also be implemented. A trigger is effectively a type of stored procedure( one that is invo%ed when a particular event occurs. -or example( you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted. &ndexes are used to find rows with specific column values quic%ly. Fithout an index( Ey A1 must begin with the first row and then read through the entire table to find the relevant rows. The larger the table( the more this costs. &f the table has an index for the columns in question( Ey A1 can quic%ly determine the position to see% to in the middle of the data file without having to loo% at all the data. &f a table has !(;;; rows( this is at least !;; times faster than reading sequentially. &f you need to access most of the rows( it is faster to read sequentially( because this minimi'es dis% see%s. What is ma3imum siIe of a database in mys.l? &f the operating system or filesystem places a limit on the number of files in a directory( Ey A1 is bound by that constraint. The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. &f the time required to open a file in the directory increases significantly as the number of files increases( database performance can be adversely affected. The amount of available dis% space limits the number of tables. Ey A1 K.,, had a ?34 /? gigabyte0 limit on table si'e. Fith the Ey& AE storage engine in Ey A1 K.,K( the maximum table si'e was increased to <MMK< terabytes /,M<= b ! bytes0. Fith this larger allowed table si'e( the maximum effective table si'e for Ey A1 databases is usually determined by operating system constraints on file si'es( not by Ey A1 internal limits. The &nnoD4 storage engine maintains &nnoD4 tables within a tablespace that can be created from several files. This allows a table to exceed the maximum individual file si'e. The tablespace can include raw dis% partitions( which allows extremely large tables. The maximum tablespace si'e is <?T4. The following table lists some examples of operating system file*si'e limits. This is only a rough guide and is not intended to be definitive. -or the most up*to*date information( be sure to chec% the documentation specific to your operating system. )perating ystem -ile*si'e 1imit 1inux ,.,*&ntel K,*bit ,34 /1- " ?340 1inux ,.?N /using extK filesystem0 ?T4 olaris 52!; !<T4 @etFare w2@ filesystem VT4 FinK, w2 -AT2-ATK, ,342?34 FinK, w2 @T- ,T4 /possibly larger0 Eac) D w2 H- N ,T4 E3!lain normaliIation conce!t? The normali'ation process involves getting our data to conform to three progressive normal forms( and a higher level of normali'ation cannot be achieved until the previous levels have been achieved /there are actually five normal forms( but the last two are mainly academic and will not be discussed0. -irst @ormal -orm The -irst @ormal -orm /or !@-0 involves removal of redundant data from hori'ontal rows. Fe want to

http://facebook.com/adarshe

ensure that there is no duplication of data in a given row( and that every column stores the least amount of information possible /ma%ing the field atomic0. econd @ormal -orm Fhere the -irst @ormal -orm deals with redundancy of data across a hori'ontal row( econd @ormal -orm /or ,@-0 deals with redundancy of data in vertical columns. As stated earlier( the normal forms are progressive( so to achieve econd @ormal -orm( your tables must already be in -irst @ormal -orm. Third @ormal -orm & have a confession to ma%e: & do not often use Third @ormal -orm. &n Third @ormal -orm we are loo%ing for data in our tables that is not fully dependant on the primary %ey( but dependant on another value in the table What8s the difference between accessing a class method via L) and via <<? "" is allowed to access methods that can perform static operations( i.e. those( which do not require object initiali'ation. What are the advantages and disadvantages of CASCAAE S*@%E SHEE*S? #xternal tyle heets Advantages .an control styles for multiple documents at once .lasses can be created for use on multiple HTE1 element types in many documents elector and grouping methods can be used to apply styles under complex contexts Disadvantages An extra download is required to import style information for each document The rendering of the document may be delayed until the external style sheet is loaded 4ecomes slightly unwieldy for small quantities of style definitions #mbedded tyle heets Advantages .lasses can be created for use on multiple tag types in the document elector and grouping methods can be used to apply styles under complex contexts @o additional downloads necessary to receive style information Disadvantage This method can not control styles for multiple documents at once &nline tyles Advantages Bseful for small quantities of style definitions .an override other style specification methods at the local level so only exceptions need to be listed in conjunction with other style methods Disadvantages Does not distance style information from content /a main goal of 3E12HTE10 .an not control styles for multiple documents at once Author can not create or control classes of elements to control multiple element types within the document elector grouping methods can not be used to create complex element addressing scenarios Fhat type of inheritance that php supportsO &n PHP an extended class is always dependent on a single base class( that is( multiple inheritance is not supported. .lasses are extended using the %eyword 8extends8. How can increase the !erformance of #yS$% select .uery? Fe can use 1&E&T to stop Ey ql for further search in table after we have received our required no. of records( also we can use 1#-T R)&@ or $&3HT R)&@ instead of full join in cases we have related data in two or more tables.

http://facebook.com/adarshe

How can we change the name of a column of a table? Ey A1 query to rename table" $#@AE# TA41# tblJname T) newJtblJname or( A1T#$ TA41# table@ame .HA@3# )ld@ame new@ame. When you want to show some !art of a te3t dis!layed on an H*#% !age in red font color? What different !ossibilities are there to do this? What are the advantagesJdisadvantages of these methods? There are , ways to show some part of a text in red" !. Bsing HTE1 tag Hfont color7+red+I ,. Bsing HTE1 tag Hspan style7+color" red+I When viewing an H*#% !age in a Prowser/ the Prowser often "ee!s this !age in its cacheD What can be !ossible advantagesJdisadvantages of !age caching? How can you !revent caching of a certain !age =!lease give several alternate solutions>? Fhen you use the metatag in the header section at the beginning of an HTE1 Feb page( the Feb page may still be cached in the Temporary &nternet -iles folder. A page that &nternet #xplorer is browsing is not cached until half of the <? C4 buffer is filled. Bsually( metatags are inserted in the header section of an HTE1 document( which appears at the beginning of the document. Fhen the HTE1 code is parsed( it is read from top to bottom. Fhen the metatag is read( &nternet #xplorer loo%s for the existence of the page in cache at that exact moment. &f it is there( it is removed. To properly prevent the Feb page from appearing in the cache( place another header section at the end of the HTE1 document. -or example" What are the different ways to login to a remote server? E3!lain the means/ advantages and disadvantages? There is at least K ways to logon to a remote server" Bse ssh or telnet if you concern with security 9ou can also use rlogin to logon to a remote server. Please give a regular e3!ression =!referably PerlJP E1 style>/ which can be used to identify the - % from within a H*#% lin" tagD Try this" 2href7+/P_+Q>0+2i How can I use the C,# com!onents in !h!? The .)E class provides a framewor% to integrate /D0.)E components into your PHP scripts. string .)E"".)E/ string moduleJname P( string serverJname P( int codepageQQ0 * .)E class constructor. Parameters" moduleJname" name or class*id of the requested component. serverJname" name of the D.)E server from which the component should be fetched. &f @B11( localhost is assumed. To allow D.)E com( allowJdcom has to be set to T$B# in php.ini. codepage * specifies the codepage that is used to convert php*strings to unicode*strings and vice versa. Possible values are .PJA.P( .PJEA..P( .PJ)#E.P( .PJ 9E4)1( .PJTH$#ADJA.P( .PJBT-= and .PJBT-V. Bsage" 6word*IGisible 7 !: 22open an empty document 6word*IDocuments*IAdd/0: 22do some weird stuff 6word*I election*ITypeText/+This is a test[+0: 6word*IDocumentsP!Q*I aveAs/+Bseless test.doc+0: 22closing word 6word*IAuit/0: 22free the object 6word*I$elease/0: 6word 7 null:

http://facebook.com/adarshe

How many ways we can give the out!ut to a browser? HTE1 output PHP( A P( R P( ervlet -unction cript 1anguage output -unction Different Type of embedded Pac%age to output to a browser What is the default session time in !h! and how can I change it? The default session time in php is until closing of browser What changes I have to do in !h!Dini file for file u!loading? Ea%e the following line uncomment li%e" : Fhether to allow HTTP file uploads. fileJuploads 7 )n : Temporary directory for HTTP uploaded files /will use system default if not : specified0. uploadJtmpJdir 7 ."Wapache,triadWtemp : Eaximum allowed si'e for uploaded files. uploadJmaxJfilesi'e 7 ,E How can I set a cron and how can I e3ecute it in -ni3/ %inu3/ and windows? .ron is very simply a 1inux module that allows you to run commands at predetermined times or intervals. &n Findows( it8s called cheduled Tas%s. The name .ron is in fact derived from the same word from which we get the word chronology( which means order of time. The easiest way to use crontab is via the crontab command. c crontab This command 8edits8 the crontab. Bpon employing this command( you will be able to enter the commands that you wish to run. Ey version of 1inux uses the text editor vi. 9ou can find information on using vi here. The syntax of this file is very important b if you get it wrong( your crontab will not function properly. The syntax of the file should be as follows" minutes hours dayJofJmonth month dayJofJwee% command All the variables( with the exception of the command itself( are numerical constants. &n addition to an asteris% />0( which is a wildcard that allows any value( the ranges permitted for each field are as follows" Einutes" ;*M5 Hours" ;*,K DayJofJmonth" !*K! Eonth" !*!, Fee%day" ;*< Fe can also include multiple values for each entry( simply by separating each value with a comma. command can be any shell command and( as we will see momentarily( can also be used to execute a Feb document such as a PHP file. o( if we want to run a script every Tuesday morning at V"!M AE( our mycronjob file will contain the following content on a single line" !M V > > , 2path2to2scriptname This all seems simple enough( rightO @ot so fast\ &f you try to run a PHP script in this manner( nothing will happen /barring very special configurations that have PHP compiled as an executable( as opposed to an Apache module0. The reason is that( in order for PHP to be parsed( it needs to be passed through Apache. &n other words( the page needs to be called via a browser or other means of retrieving Feb content. -or our purposes( &8ll assume that your server configuration includes wget( as is the case with most default configurations. To test your configuration( log in to shell. &f you8re using an $PE*based system

http://facebook.com/adarshe

/e.g. $edhat or Eandra%e0( type the following" c wget help &f you are greeted with a wget pac%age identification( it is installed in your system. 9ou could execute the PHP by invo%ing wget on the B$1 to the page( li%e so" c wget http"22www.example.com2file.php @ow( let8s go bac% to the mailstoc%.php file we created in the first part of this article. Fe saved it in our document root( so it should be accessible via the &nternet. $emember that we wanted it to run at ?PE #astern time( and send you your precious closing bell reportO ince &8m located in the #astern time'one( we can go ahead and set up our crontab to use ?";;( but if you live elsewhere( you might have to compensate for the time difference when setting this value. This is what my crontab will loo% li%e" ; ? > > !(,(K(?(M wget http"22www.example.com2mailstoc%.php Ste!s for the !ayment gateway !rocessing? An online payment gateway is the interface between your merchant account and your Feb site. The online payment gateway allows you to immediately verify credit card transactions and authori'e funds on a customer8s credit card directly from your Feb site. &t then passes the transaction off to your merchant ban% for processing( commonly referred to as transaction batching How many ways I can redirect a PHP !age? Here are the possible ways of php page redirection. !. Bsing Rava script" 8: echo 8window.location.href7+8.6filename.8+:8: echo 88: echo 88: echo 88: echo 88: U U redirect/8http"22maosjb.com80: OI ,. Bsing php function" header/+1ocation"http"22maosjb.com +0: %ist out different arguments in PHP header function? void header / string string P( bool replace P( int httpJresponseJcodeQQ0 What ty!e of headers have to be added in the mail function to attach a file? 6boundary 7 8**8 . mdM/ uniqid / rand/0 0 0: 6headers 7 +-rom" W+EeW+Wn+: 6headers .7 +E&E#*Gersion" !.;Wn+: 6headers .7 +.ontent*Type" multipart2mixed: boundary7W+6boundaryW++: How to store the u!loaded file to the final location? moveJuploadedJfile / string filename( string destination0 This function chec%s to ensure that the file designated by filename is a valid upload file /meaning that it was uploaded via PHP8s HTTP P) T upload mechanism0. &f the file is valid( it will be moved to the filename given by destination. &f filename is not a valid upload file( then no action will occur( and moveJuploadedJfile/0 will return -A1 #. &f filename is a valid upload file( but cannot be moved for some reason( no action will occur( and moveJuploadedJfile/0 will return -A1 #. Additionally( a warning will be issued. What is the difference between e!lyLto and eturnL!ath in the headers of a mail function? $eply*to" $eply*to is where to delivery the reply of the mail.

http://facebook.com/adarshe

$eturn*path" $eturn path is when there is a mail delivery failure occurs then where to delivery the failure notification. E3!lain about *y!e Buggling in !h!? PHP does not require /or support0 explicit type definition in variable declaration: a variable8s type is determined by the context in which that variable is used. That is to say( if you assign a string value to variable 6var( 6var becomes a string. &f you then assign an integer value to 6var( it becomes an integer. An example of PHP8s automatic type conversion is the addition operator 8N8. &f any of the operands is a float( then all operands are evaluated as floats( and the result will be a float. )therwise( the operands will be interpreted as integers( and the result will also be an integer. @ote that this does @)T change the types of the operands themselves: the only change is in how the operands are evaluated. 6foo N7 ,: 22 6foo is now an integer /,0 6foo 7 6foo N !.K: 22 6foo is now a float /K.K0 6foo 7 M N +!; 1ittle Piggies+: 22 6foo is integer /!M0 6foo 7 M N +!; mall Pigs+: 22 6foo is integer /!M0 &f the last two examples above seem odd( see tring conversion to numbers. &f you wish to change the type of a variable( see settype/0. &f you would li%e to test any of the examples in this section( you can use the varJdump/0 function. @ote" The behavior of an automatic conversion to array is currently undefined. ince PHP /for historical reasons0 supports indexing into strings via offsets using the same syntax as array indexing( the example above leads to a problem" should 6a become an array with its first element being +f+( or should +f+ become the first character of the string 6aO The current versions of PHP interpret the second assignment as a string offset identification( so 6a becomes +f+( the result of this automatic conversion however should be considered undefined. PHP ? introduced the new curly brac%et syntax to access characters in string( use this syntax instead of the one presented above" How can I embed a 2ava !rogramme in !h! file and what changes have to be done in !h!Dini file? There are two possible ways to bridge PHP and Rava" you can either integrate PHP into a Rava ervlet environment( which is the more stable and efficient solution( or integrate Rava support into PHP. The former is provided by a AP& module that interfaces with the ervlet server( the latter by this Rava extension. The Rava extension provides a simple and effective means for creating and invo%ing methods on Rava objects from PHP. The RGE is created using R@&( and everything runs in*process. #xample .ode" getProperty/8java.version80 . 88: echo 8Rava vendor78 . 6system*IgetProperty/8java.vendor80 . 88: echo 8) 78 . 6system*IgetProperty/8os.name80 . 8 8 . 6system*IgetProperty/8os.version80 . 8 on 8 . 6system* IgetProperty/8os.arch80 . 8 8: 22 java.util.Date example 6formatter 7 new Rava/8java.text. impleDate-ormat8( +####( EEEE dd( yyyy 8at8 h"mm"ss a ''''+0: echo 6formatter*Iformat/new Rava/8java.util.Date800: OI The behaviour of these functions is affected by settings in php.ini. Table !. Rava configuration options @ame Default .hangeable java.class.path @B11 PHPJ&@&JA11 @ame Default .hangeable java.home @B11 PHPJ&@&JA11 java.library.path @B11 PHPJ&@&JA11 java.library

http://facebook.com/adarshe

RAGA1&4 PHPJ&@&JA11 How *o *urn ,n the Session Su!!ort? The session support can be turned on automatically at the site level( or manually in each PHP page script"

Turning on session support automatically at the site level" et session.autoJstart 7 ! in php.ini. Turning on session support manually in each page script" .all sessionJstart/0 funtion.

E3!lain the ternary conditional o!erator in PHP? #xpression preceding the O is evaluated( if itSs true( then the expression preceding the " is executed( otherwise( the expression following " is executed. What8s the difference between include and re.uire? &tSs how they handle failures. &f the file is not found by require/0( it will cause a fatal error and halt the execution of the script. &f the file is not found by include/0( a warning will be issued( but execution will continue. How many ways can we get the value of current session id? sessionJid/0 returns the session id for the current session. How can we destroy the coo"ie? et the coo%ie in past. How *o ead the Entire +ile into a Single String? &f you have a file( and you want to read the entire file into a single string( you can use the fileJgetJcontents/0 function. &t opens the specified file( reads all characters in the file( and returns them in a single string. Here is a PHP script example on how to fileJgetJcontents/0" HOphp 6file 7 fileJgetJcontents/+2windows2systemK,2drivers2etc2services+0: print/+ i'e of the file" +.strlen/6file0.+Wn+0: OI This script will print" i'e of the file" =!!<

http://facebook.com/adarshe

Potrebbero piacerti anche