• +91 9723535972
  • info@interviewmaterial.com

PHP Interview Questions and Answers

PHP Interview Questions and Answers

Question - 11 : - What is meant by urlencode and urldecode?

Answer - 11 : - 1) -urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs. urldecode() returns the URL decoded version of the given string. 2) - string urlencode(str) - Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version: Alphanumeric characters are maintained as is. Space characters are converted to "+" characters. Other non-alphanumeric characters are converted "%" followed by two hex digits representing the converted character. string urldecode(str) - Returns the original string of the input URL encoded string. For example: $discount ="10.00%"; $url = "http://exammaterial.com/submit.php?disc=".urlencode($discount); echo $url; You will get "http://exammaterial.com/submit.php?disc=10%2E00%25".

Question - 12 : - How To Get the Uploaded File Information in the Receiving Script?

Answer - 12 : - Once the Web 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 $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as: $_FILES[$fieldName]['name'] - The Original file name on the browser system. $_FILES[$fieldName]['type'] - The file type determined by the browser. $_FILES[$fieldName]['size'] - The Number of bytes of the file content. $_FILES[$fieldName]['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server. $_FILES[$fieldName]['error'] - The error code associated with this file upload. The $fieldName is the name used in the .

Question - 13 : - What is the difference between mysql_fetch_object and mysql_fetch_array?

Answer - 13 : - MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array

Question - 14 : - How can I execute a PHP script using command line?

Answer - 14 : - Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

Question - 15 : - I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

Answer - 15 : - PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

Question - 16 : - Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?

Answer - 16 : - In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.

Question - 17 : - What are the different tables present in MySQL? Which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10))?

Answer - 17 : - Total 5 types of tables we can create 1. MyISAM 2. Heap 3. Merge 4. INNO DB 5. ISAM MyISAM is the default storage engine as of MySQL 3.23. When you fire the above create query MySQL will create a MyISAM table.

Question - 18 : - How To Create a Table?

Answer - 18 : - If you want to create a table, you can run the CREATE TABLE statement as shown in the following sample script: Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script, you will get something like this: Table Tech_links created.

Question - 19 : - How can we encrypt the username and password using PHP?

Answer - 19 : - 1) - You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password"); 2) - You can use the MySQL PASSWORD() function to encrypt username and password. For example, INSERT into user (password, ...) VALUES (PASSWORD($password”)), ...);

Question - 20 : - How do you pass a variable by value?

Answer - 20 : - Just like in C++, put an ampersand in front of it, like $a = &$b


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners