InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Is File Upload? |
|
Answer» File UPLOAD is Web page FUNCTION which allows visitor to specify a file on the browser's system and submit it to the Web server. This is a very USEFUL function for many interactive Web sites. Some examples are:
Which HTML Tag Allows Users to Specify a File for Uploading? File upload is Web page function which allows visitor to specify a file on the browser's system and submit it to the Web server. This is a very useful function for many interactive Web sites. Some examples are: Which HTML Tag Allows Users to Specify a File for Uploading? |
|
| 2. |
What Is A Result Set Object? |
|
Answer» A result set object is a logical representation of data rows returned by mysql_query() function on SELECT statements. Every result set object has an INTERNAL pointer USED to identify the current row in the result set. Once you GET a result set object, you can USE the following functions to retrieve detail information: A result set object is a logical representation of data rows returned by mysql_query() function on SELECT statements. Every result set object has an internal pointer used to identify the current row in the result set. Once you get a result set object, you can use the following functions to retrieve detail information: |
|
| 3. |
How To Get The Number Of Rows Selected Or Affected By A Sql Statement? |
|
Answer» There are two functions you can USE the get the number of ROWS selected or affected by a SQL statement:
There are two functions you can use the get the number of rows selected or affected by a SQL statement: |
|
| 4. |
How To Run A Sql Statement? |
|
Answer» You can run any types of SQL STATEMENTS through the mysql_query() FUNCTION. It takes the SQL statement as a STRING and returns different types of data depending on the SQL statement type and execution status: You can run any types of SQL statements through the mysql_query() function. It takes the SQL statement as a string and returns different types of data depending on the SQL statement type and execution status: |
|
| 5. |
How To Connect To Mysql From A Php Script? |
|
Answer» If you want ACCESS the MySQL SERVER, you must create a connection object first by calling the mysql_connect() function in the following format: If you want access the MySQL server, you must create a connection object first by calling the mysql_connect() function in the following format: |
|
| 6. |
What Do You Need To Connect Php To Mysql? |
|
Answer» If you WANT to access MySQL database server in your PHP script, you need to make sure that MySQL module is installed and turned on in your PHP engine. CHECK the PHP configuration file, php.ini, to make sure the extension=php_mysql.dll is not commented out. If you want to access MySQL database server in your PHP script, you need to make sure that MySQL module is installed and turned on in your PHP engine. Check the PHP configuration file, php.ini, to make sure the extension=php_mysql.dll is not commented out. |
|
| 7. |
What Is Session_register()? |
|
Answer» session_register() is OLD function that REGISTERS global variables into the current session. You should stop using session_register() and USE array $_SESSION to save values into the current session now. session_register() is old function that registers global variables into the current session. You should stop using session_register() and use array $_SESSION to save values into the current session now. |
|
| 8. |
How To Close A Session Properly? |
|
Answer» Let's say you site requires users to login. When a logged in user CLICKS the logout BUTTON, you need to close the session associated with this user properly in 3 steps: Let's say you site requires users to login. When a logged in user clicks the logout button, you need to close the session associated with this user properly in 3 steps: |
|
| 9. |
How To Remove Values Saved In The Current Session? |
|
Answer» If you want to remove values saved in the CURRENT session, you should USE the UNSET() function on those saved values in $_SESSION, or use array() to EMPTY $_SESSION:
If you want to remove values saved in the current session, you should use the unset() function on those saved values in $_SESSION, or use array() to empty $_SESSION: |
|
| 10. |
How To Set Session.gc_divisor Properly? |
|
Answer» As you know that session.gc_divisor is the FREQUENCY of when the session GARBAGE collection process will be executed. You should SET this value based on the income request traffic. Here are some suggestions: As you know that session.gc_divisor is the frequency of when the session garbage collection process will be executed. You should set this value based on the income request traffic. Here are some suggestions: |
|
| 11. |
How To Set Session.gc_maxlifetime Properly? |
|
Answer» As you know that session.gc_maxlifetime is the session value timeout period. You should SET this value based on the USAGE pattern of your visitors. Here are some suggestions: As you know that session.gc_maxlifetime is the session value timeout period. You should set this value based on the usage pattern of your visitors. Here are some suggestions: |
|
| 12. |
What Is The Timeout Period On Session Values? |
|
Answer» The PHP engine has no DIRECT settings on session timeout period. But it has a session garbage collection mechanism that you can set to remove those special files containing session values. There are 3 settings you can use to define the session garbage collection mechanism: The PHP engine has no direct settings on session timeout period. But it has a session garbage collection mechanism that you can set to remove those special files containing session values. There are 3 settings you can use to define the session garbage collection mechanism: |
|
| 13. |
Is It More Secure To Use Cookies To Transfer Session Ids? |
|
Answer» yes, because attacking your WEB site using URL PARAMETERS is much easier than using cookies. yes, because attacking your Web site using URL parameters is much easier than using cookies. |
|
| 14. |
What Are The Options To Transfer Session Ids? |
|
Answer» Once a new session is created, its session ID MUST be transferred to the CLIENT browser and included in the next client request, so that the PHP engine can find the same session created by the same visitor. The PHP engine has two options to transfer the session ID to the client browser:
The PHP engine is configured to use URL parameters for transferring session IDs by DEFAULT. Once a new session is created, its session ID must be transferred to the client browser and included in the next client request, so that the PHP engine can find the same session created by the same visitor. The PHP engine has two options to transfer the session ID to the client browser: The PHP engine is configured to use URL parameters for transferring session IDs by default. |
|
| 15. |
How Does Firefox Manage Cookies? |
|
Answer» FireFox browser allows you to delete old cookies, and gives you options to keep persistent cookies in cookie files until they REACH their EXPIRATION time. The following tutorial shows you how to manage cookies in FireFox: FireFox browser allows you to delete old cookies, and gives you options to keep persistent cookies in cookie files until they reach their expiration time. The following tutorial shows you how to manage cookies in FireFox: |
|
| 16. |
How To Delete Cookie Files On Your Computer? |
|
Answer» A simple way to delete cookie files on your COMPUTER is to use the FUNCTION offered by the IE browser. The following tutorial EXERCISE shows you how to delete cookie files created by IE: A simple way to delete cookie files on your computer is to use the function offered by the IE browser. The following tutorial exercise shows you how to delete cookie files created by IE: |
|
| 17. |
Where Are The Persistent Cookies Stored On Your Computer? |
|
Answer» The location and file names where persistent cookies are stored on your computer depend on which browser you are using. If you using Microsoft Internet Explorer, persistent cookies are stored in the \Documents and Settings\$user\Cookies DIRECTORY. Cookies are stored in multiple cookie files with one file per WEB SERVER. Check your cookie directory on your local SYSTEM, you will be surprised to see how many Web SERVERS are setting persistent cookies to your computer. The location and file names where persistent cookies are stored on your computer depend on which browser you are using. If you using Microsoft Internet Explorer, persistent cookies are stored in the \Documents and Settings\$user\Cookies directory. Cookies are stored in multiple cookie files with one file per Web server. Check your cookie directory on your local system, you will be surprised to see how many Web servers are setting persistent cookies to your computer. |
|
| 18. |
How Cookies Are Transported From Browsers To Servers? |
|
Answer» Cookies are transported from a WEB browser to a Web SERVER in the header area of the HTTP request message. Each COOKIE will be included in a separate "Cookie:" header line in the following format: Cookies are transported from a Web browser to a Web server in the header area of the HTTP request message. Each cookie will be included in a separate "Cookie:" header line in the following format: |
|
| 19. |
How Cookies Are Transported From Servers To Browsers? |
|
Answer» Cookies are transported from a WEB server to a Web browser in the header area of the HTTP response MESSAGE. Each COOKIE will be included in a SEPARATE "Set-Cookie:" header line in the following format: Cookies are transported from a Web server to a Web browser in the header area of the HTTP response message. Each cookie will be included in a separate "Set-Cookie:" header line in the following format: |
|
| 20. |
How To Receive A Cookie From The Browser? |
|
Answer» If you know that a cookie has been sent to the BROWSER when it was visiting the server PREVIOUSLY, you can check the built-in $_COOKIE array, which contains all COOKIES that were sent by the server previously. The script below shows you how to pickup one cookie from the $_COOKIE and loop through all cookies in $_COOKIE: If you know that a cookie has been sent to the browser when it was visiting the server previously, you can check the built-in $_COOKIE array, which contains all cookies that were sent by the server previously. The script below shows you how to pickup one cookie from the $_COOKIE and loop through all cookies in $_COOKIE: |
|
| 21. |
How To Send A Cookie To The Browser? |
|
Answer» If you want to sent a cookie to the browser when it comes to request your PHP page, you can use the setcookie( ) function. Note that you should call setcookie() function before any output statements. The following script shows you how to SET COOKIES: If you want to sent a cookie to the browser when it comes to request your PHP page, you can use the setcookie( ) function. Note that you should call setcookie() function before any output statements. The following script shows you how to set cookies: |
|
| 22. |
How To Support Multiple-page Forms? |
|
Answer» If you have a long form with a lots of fields, you may want to DIVIDE the fields into MULTIPLE groups and present multiple pages with one group of fields on one page. This makes the a long form more user-friendly. However, this requires you to write good scripts that: If you have a long form with a lots of fields, you may want to divide the fields into multiple groups and present multiple pages with one group of fields on one page. This makes the a long form more user-friendly. However, this requires you to write good scripts that: |
|
| 23. |
How To Retrieve The Original Query String? |
|
Answer» If you have CODED some values in the URL without USING the standard form GET format, you need to retrieve those values in the ORIGINAL query string in $_SERVER['QUERY_STRING']. The script below is an ENHANCED version of processing_forms.php which print the original query string: If you have coded some values in the URL without using the standard form GET format, you need to retrieve those values in the original query string in $_SERVER['QUERY_STRING']. The script below is an enhanced version of processing_forms.php which print the original query string: |
|
| 24. |
How To List All Values Of Submitted Fields? |
|
Answer» If you want list all values of submitted FIELDS, you can write a simple LOOP to retrieve all ENTRIES in the $_REQUEST array. Below is an improved version of processing_forms.php to list all submited input values: If you want list all values of submitted fields, you can write a simple loop to retrieve all entries in the $_REQUEST array. Below is an improved version of processing_forms.php to list all submited input values: |
|
| 25. |
How To Avoid The Undefined Index Error? |
|
Answer» If you don't want your PHP page to give out errors as shown in the PREVIOUS exercise, you should consider checking all expected input FIELDS in $_REQUEST with the isset() FUNCTION as shown in the example script below: If you don't want your PHP page to give out errors as shown in the previous exercise, you should consider checking all expected input fields in $_REQUEST with the isset() function as shown in the example script below: |
|
| 26. |
What Happens If An Expected Input Field Was Not Submitted? |
|
Answer» Obviously, if an expected input field was not submitted, there will no entry in the $_REQUEST array for that field. You may get an execution error, if you are not checking the EXISTENCE of the expected entries in $_REQUEST. For example, if you copy processing_forms.php to your local Web server, and run your browser with http://localhost/processing_forms.php?name=Joe, you will an error page like this: Obviously, if an expected input field was not submitted, there will no entry in the $_REQUEST array for that field. You may get an execution error, if you are not checking the existence of the expected entries in $_REQUEST. For example, if you copy processing_forms.php to your local Web server, and run your browser with http://localhost/processing_forms.php?name=Joe, you will an error page like this: |
|
| 27. |
Where Is The Submitted Form Data Stored? |
|
Answer» When a user submit a FORM on your WEB server, user entered data will be TRANSFERRED to the PHP engine, which will make the submitted data available to your PHP script for PROCESSING in pre-defined ARRAYS: When a user submit a form on your Web server, user entered data will be transferred to the PHP engine, which will make the submitted data available to your PHP script for processing in pre-defined arrays: |
|
| 28. |
How To Generate A Form? |
|
Answer» Generating a form seems to be easy. You can use PHP output statements to generate the required <FORM> tag and other input tags. But you should consider to organized your input fields in a table to make your form looks good on the screen. The PHP script below shows you a good example of HTML forms: Generating a form seems to be easy. You can use PHP output statements to generate the required <FORM> tag and other input tags. But you should consider to organized your input fields in a table to make your form looks good on the screen. The PHP script below shows you a good example of HTML forms: |
|
| 29. |
What Are Form Input Html Tags? |
|
Answer» HTML TAGS that can be used in a form to collect INPUT data are: HTML tags that can be used in a form to collect input data are: |
|
| 30. |
How To Create A Web Form? |
|
Answer» If you take input data from visitors on your Web site, you can create a Web form with input fields to ALLOW visitors to fill in data and submit the data to your server for processing. A Web form can be created with the <FORM> tag with some input tags. The &FORM tag should be written in the FOLLOWING format: If you take input data from visitors on your Web site, you can create a Web form with input fields to allow visitors to fill in data and submit the data to your server for processing. A Web form can be created with the <FORM> tag with some input tags. The &FORM tag should be written in the following format: |
|
| 31. |
How To Break A File Path Name Into Parts? |
|
Answer» If you have a file NAME, and want to get different parts of the file name, you can use the pathinfo() function. It breaks the file name into 3 parts: directory name, file base name and file extension; and returns them in an ARRAY. Here is a PHP script example on how to use pathinfo(): If you have a file name, and want to get different parts of the file name, you can use the pathinfo() function. It breaks the file name into 3 parts: directory name, file base name and file extension; and returns them in an array. Here is a PHP script example on how to use pathinfo(): |
|
| 32. |
How To Get The Directory Name Out Of A File Path Name? |
|
Answer» If you have the full path NAME of a file, and WANT to get the directory name portion of the path name, you can USE the dirname() function. It BREAKS the full path name at the last directory path delimiter (/) or (\), and returns the first portion as the directory name. Here is a PHP script example on how to use dirname(): If you have the full path name of a file, and want to get the directory name portion of the path name, you can use the dirname() function. It breaks the full path name at the last directory path delimiter (/) or (\), and returns the first portion as the directory name. Here is a PHP script example on how to use dirname(): |
|
| 33. |
How To Copy A File? |
|
Answer» If you have a FILE and WANT to make a COPY to create a NEW file, you can use the copy() function. Here is a PHP script example on how to use copy(): If you have a file and want to make a copy to create a new file, you can use the copy() function. Here is a PHP script example on how to use copy(): |
|
| 34. |
How To Remove A File? |
|
Answer» If you WANT to remove an existing file, you can USE the unlink() function. Here is a PHP script example on how to use unlink(): If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink(): |
|
| 35. |
How To Remove An Empty Directory? |
|
Answer» If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir(): If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir(): |
|
| 36. |
How To Create A Directory? |
|
Answer» You can use the MKDIR() function to create a DIRECTORY. Here is a PHP script example on how to use mkdir(): You can use the mkdir() function to create a directory. Here is a PHP script example on how to use mkdir(): |
|
| 37. |
How To Open Standard Output As A File Handle? |
|
Answer» If you want to open the standard OUTPUT as a file handle yourself, you can use the fopen("php://stdout") function. It CREATES a special file handle linking to the standard output, and returns the file handle. Once the standard output is opened to a file handle, you can use fwrite() to write data to the STARNDARD output like a regular file. Here is a PHP script example on how to write to standard output: If you want to open the standard output as a file handle yourself, you can use the fopen("php://stdout") function. It creates a special file handle linking to the standard output, and returns the file handle. Once the standard output is opened to a file handle, you can use fwrite() to write data to the starndard output like a regular file. Here is a PHP script example on how to write to standard output: |
|
| 38. |
How To Read A File In Binary Mode? |
|
Answer» If you have a file that stores binary data, like an executable program or picture file, you need to READ the file in binary mode to ensure that none of the data gets modified during the reading process. You need to: If you have a file that stores binary data, like an executable program or picture file, you need to read the file in binary mode to ensure that none of the data gets modified during the reading process. You need to: |
|
| 39. |
How To Read One Character From A File? |
|
Answer» If you have a text file, and you want to read the file one character at a time, you can use the FGETC() function. It reads the current character, moves the file pointer to the next character, and returns the character as a string. If end of the file is reached, fgetc() returns Boolean false. Here is a PHP script example on how to use fgetc(): If you have a text file, and you want to read the file one character at a time, you can use the fgetc() function. It reads the current character, moves the file pointer to the next character, and returns the character as a string. If end of the file is reached, fgetc() returns Boolean false. Here is a PHP script example on how to use fgetc(): |
|
| 40. |
How To Open A File For Writing? |
|
Answer» If you WANT to OPEN a new file and write date to the file, you can use the fopen($fileName, "w") function. It creates the SPECIFIED file, and returns a file handle. The SECOND argument "w" tells PHP to open the file for writing. Once the file is open, you can use other functions to write data to the file through this file handle. Here is a PHP script example on how to use fopen() for writing: If you want to open a new file and write date to the file, you can use the fopen($fileName, "w") function. It creates the specified file, and returns a file handle. The second argument "w" tells PHP to open the file for writing. Once the file is open, you can use other functions to write data to the file through this file handle. Here is a PHP script example on how to use fopen() for writing: |
|
| 41. |
How To Open A File For Reading? |
|
Answer» If you want to open a file and READ its contents piece by piece, you can use the fopen($fileName, "r") function. It opens the SPECIFIED file, and returns a file handle. The second argument "r" TELLS PHP to open the file for reading. Once the file is open, you can use other functions to read data from the file through this file handle. Here is a PHP script example on how to use fopen() for reading: If you want to open a file and read its contents piece by piece, you can use the fopen($fileName, "r") function. It opens the specified file, and returns a file handle. The second argument "r" tells PHP to open the file for reading. Once the file is open, you can use other functions to read data from the file through this file handle. Here is a PHP script example on how to use fopen() for reading: |
|
| 42. |
How To Read The Entire File Into A Single String? |
|
Answer» If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It 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 file_get_contents(): If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It 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 file_get_contents(): |
|
| 43. |
How To Define A Function With Any Number Of Arguments? |
|
Answer» If you want to define a FUNCTION with any number of arguments, you need to: If you want to define a function with any number of arguments, you need to: |
|
| 44. |
How To Specify Argument Default Values? |
|
Answer» If you want to ALLOW the caller to skip an argument when calling a function, you can define the argument with a default VALUE when defining the function. Adding a default value to an argument can be done like this "function name($arg=expression){}. Here is a PHP script on how to specify default values to ARGUMENTS: If you want to allow the caller to skip an argument when calling a function, you can define the argument with a default value when defining the function. Adding a default value to an argument can be done like this "function name($arg=expression){}. Here is a PHP script on how to specify default values to arguments: |
|
| 45. |
How To Access A Global Variable Inside A Function? |
|
Answer» By DEFAULT, global variables are not ACCESSIBLE inside a function. However, you can MAKE them accessible by declare them as "global" inside a function. Here is a PHP SCRIPT on declaring "global" variables: By default, global variables are not accessible inside a function. However, you can make them accessible by declare them as "global" inside a function. Here is a PHP script on declaring "global" variables: |
|
| 46. |
What Is The Scope Of A Variable Defined Outside A Function? |
|
Answer» A VARIABLE defined OUTSIDE any functions in main script body is called global variable. However, a global variable is not really accessible globally any in the script. The scope of global variable is LIMITED to all statements outside any functions. So you can not access any global VARIABLES inside a function. Here is a PHP script on the scope of global variables: A variable defined outside any functions in main script body is called global variable. However, a global variable is not really accessible globally any in the script. The scope of global variable is limited to all statements outside any functions. So you can not access any global variables inside a function. Here is a PHP script on the scope of global variables: |
|
| 47. |
What Is The Scope Of A Variable Defined In A Function? |
|
Answer» The scope of a LOCAL variable defined in a FUNCTION is limited with that function. Once the function is ended, its local variables are also removed. So you can not ACCESS any local variable outside its defining function. Here is a PHP script on the scope of local variables in a function: The scope of a local variable defined in a function is limited with that function. Once the function is ended, its local variables are also removed. So you can not access any local variable outside its defining function. Here is a PHP script on the scope of local variables in a function: |
|
| 48. |
Can You Define An Array Argument As A Reference Type? |
|
Answer» You can define an ARRAY argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an array argument as a reference type: You can define an array argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an array argument as a reference type: |
|
| 49. |
How Arrays Are Passed Through Arguments? |
|
Answer» Like a normal variable, an ARRAY is passed through an argument by value, not by REFERENCE. That means when an array is passed as an argument, a copy of the array will be passed into the function. Modipickzyng that copy INSIDE the function will not impact the original copy. Here is a PHP script on passing arrays by values: Like a normal variable, an array is passed through an argument by value, not by reference. That means when an array is passed as an argument, a copy of the array will be passed into the function. Modipickzyng that copy inside the function will not impact the original copy. Here is a PHP script on passing arrays by values: |
|
| 50. |
Can You Pass An Array Into A Function? |
|
Answer» You can pass an ARRAY into a function in the same as a normal variable. No special syntax needed. Here is a PHP script on how to pass an array to a function: You can pass an array into a function in the same as a normal variable. No special syntax needed. Here is a PHP script on how to pass an array to a function: |
|