PHP Interview Questions
- 0of 0 votes
AnswersHow to insert excel file that contain paragraph into mysql using php
- bikesh2 June 22, 2016 in India for abc| Report Duplicate | Flag | PURGE
abc PHP - 0of 0 votes
AnswerCreate a table row with the following
- Poornima August 21, 2015 in United States
Course
Specialization
Name of the Institute
Location
Graduation Year
Aggregate Marks
The code should automatically create a new row to add a new entry
Display all the courses (from 10th Std) in the screen| Report Duplicate | Flag | PURGE
PHP - 0of 0 votes
AnswersImplement the function accumulate below in the language of your choice. The code is in PHP but the syntax of this question should translate into any language. You should have enough information from the comments to define this function correctly. You do not need to implement the function calc.
/**
* This interface should be implemented to represent doing a binary operation on two integers
*/interface iBinaryOperator { /** * This will take int $x and int $y and return an integer value or throw an exception * * @param int $x * @param int $y * @return int the value of the binary operation of $x and $y * @throws MathException */ public function calc($x, $y); } /** * This function should go through the array of operands and run calc on each operand IN ORDER, then * return the accumulated value. * * For example the code below would echo the value 10: * * $op = new Addition(); //class Addition obviously implements iBinaryOperator * $operands = array(5,2,3); * echo accumulate($op, $operands); * * This function should work for ANY size array of operands, and ANY class that implements iBinaryOperator * * @param iBinaryOperator $op * @param array $operands array of integers of size N, can be empty * @return int|string returns an int on successful accumulation, or the string 'error' in error conditions */ function accumulate(iBinaryOperator $op, array $operands) {//Add code here in the language of your choice
}
- printfNum December 19, 2013 in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer PHP - 0of 0 votes
AnswersThere is a function that scans an array of characters for the character 'e' and prints out each index. What is the complexity? Please implement this function in C, C++, PHP or JavaScript.
- printfNum December 19, 2013 in United States
If I sort the array, what is the complexity of the sort? What type of sort?
After sorting, what is the complexity if I rescan the array for the character 'e'?| Report Duplicate | Flag | PURGE
Software Engineer / Developer PHP - -2of 2 votes
Answershow to send message using php script ?
- Surender July 12, 2013 in India| Report Duplicate | Flag | PURGE
JP Morgan Applications Developer PHP - 0of 0 votes
AnswersGiven an integer, return all sequences of numbers that sum to it. (Example: 3 -> (1, 2), (2, 1), (1, 1, 1)). Interview was for a php position.
- AnthonyKiedis January 23, 2013 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm PHP - 0of 0 votes
Answershow to make a form which shows some text and there is some button but when you click on one button it , open another form in the same page and in that subform there is one submit button ,when you click that submit button then that sub form should disappear. thanks in advance
- sonia upadhaya September 06, 2012 in United States| Report Duplicate | Flag | PURGE
PHP - 0of 0 votes
AnswersThere is integer array like {1,2,4,5,6,1,2,4,3,5,7,2,1}. I want to find the possible combination of pair which sum is 4.
- amitnagar21 January 03, 2012 in India
input : {1,2,4,5,6,1,2,4,3,5,7,2,1}
output : {1,1,2}, {2,2}, {3,1}, {1,2,1}...etc which make the sum as 4| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm PHP - 0of 0 votes
AnswersMemory management in PHP
- Girlie June 29, 2011| Report Duplicate | Flag | PURGE
Google Developer Program Engineer PHP - 0of 0 votes
AnswerPass by value and pass by reference in PHP
- Girlie June 29, 2011| Report Duplicate | Flag | PURGE
Google Developer Program Engineer PHP - 0of 0 votes
AnswerWhat function(s) or hook(s) would you use in Drupal to define a url that maps to a function?
- Annonymous.... November 01, 2009
• hook_url
• hook_menu
• hook_form
• hook_uri| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat function(s) or hook(s) would you use in Drupal to create a link?
- Annonymous.... November 01, 2009
• link()
• url()
• l()
• create_link()| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerWhat does the GD library do?
- Annonymous.... November 01, 2009| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersHow can you get round the stateless nature of HTTP using PHP?
- Annonymous.... November 01, 2009| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerWhich of the following characters anchors a regular expression pattern to the start of a string?
- Annonymous.... November 01, 2009
• ^ (caret)
• $ (dollar)
• % (percentage)
• ! (exclamation mark)
• * (asterisk)| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerWhat does the following code do? Explain what’s going on there.
- Annonymous.... November 01, 2009
$date='08/26/2003';
print ereg_replace(“([0-9]+)/([0-9]+)/([0-9]+)”,”\\2/\\1/\\3”,$date);| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat function would you use to pull an associative array of results in mysql? An indexed array?
- Annonymous.... November 01, 2009
• mysql_query
• mysql_fetch_array
• mysql_fetch_row
• mysql_result| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat function can you use to open a file for reading and writing?
- Annonymous.... November 01, 2009
1. fget();
2. file_open();
3. fopen();
4. open_file();| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat function would you use to redirect the browser to a new page?
- Annonymous.... November 01, 2009
1. redir()
2. header()
3. location()
4. redirect()| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerGiven the following code:
- Annonymous.... November 01, 2009
class myclass {
private $var = '';
var $var2 = 'test';
public function print_var() {
if (!empty($this->var)) {
print $this->var .'(Var1)';
}
else {
print $this->var2 .'(Var2)';
}
}
public function __set($string, $value) {
$this->$string = $value;
}
}
$myclass = new myclass();
$myclass->var = 'Hey there!';
$myclass->print_var();
What happens if $myclass->var is replaced with $myclass->var2?
• It prints ‘Hey There(Var2)’ to the screen.
• It prints ‘test’ to the screen because var is never correctly set.
• It throws an error because you haven’t set privacy settings for var2.
• It prints (Var1) to the screen because var is a blank string, not empty.| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersGiven the following code:
- Annonymous.... November 01, 2009
class myclass {
private $var = '';
var $var2 = 'test';
public function print_var() {
if (!empty($this->var)) {
print $this->var .'(Var1)';
}
else {
print $this->var2 .'(Var2)';
}
}
public function __set($string, $value) {
$this->$string = $value;
}
}
$myclass = new myclass();
$myclass->var = 'Hey there!';
$myclass->print_var();
What happens when the code above is executed?
• It prints ‘Hey There(Var1)’ to the screen.
• It throws a fatal error because var is inaccessible in this context.
• It prints ‘test’ to the screen because var is never correctly set.
• It throws an error because you haven’t set privacy settings for var2.| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhich of the following guarantees that the first letter of a string is capitalized and all other letters of a string are lower case?
- Annonymous.... November 01, 2009
• ucfirst($str);
• strtolower(ucfirst($str));
• strtoupper($str[0]);
• ucfirst(strtolower($str));
• strtoupper(strtolower($str)[0]);| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersA class is written so that it cannot be extended. Which of the following PHP 5 keywords achieves that goal?
- Annonymous.... November 01, 2009
• Static
• Abstract
• Private
• Terminal
• Final| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersIf $a = TRUE, $b = 1. What does $a == $b equal? $a === $b?
- Annonymous.... November 01, 2009
• TRUE, FALSE
• TRUE, TRUE
• FALSE, FALSE
• FALSE, TRUE| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat is the difference between foo() & @foo()?
- Annonymous.... November 01, 2009| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerWhat functions can you use to add library code to the currently running script?
- Annonymous.... November 01, 2009| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswerIn PHP5, what code would the following print to the browser? Why?
- Annonymous.... November 01, 2009
$string = 'Hello';
function hello(&$string = '') {
$string .= ' World!';
print trim($string);
}
hello();
hello($string);
hello($string);
• World!Hello World!Hello Hello World!
• Hello World!Hello World! World!
• World!Hello World!Hello World! World!
• Hello World!Hello World!Hello World! World!
• Nothing. It would throw an error.| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWhat would the following code print to the browser? Why?
- Annonymous.... November 01, 2009
$num = 10;
function multiply(){
$num = $num * 10; }
multiply();
echo $num;| Report Duplicate | Flag | PURGE
Achieve Internet Software Engineer / Developer PHP - 0of 0 votes
AnswersWrite a class to extract basic data from an Amazon Product Detail web page when passed a URL The following information must be extracted into an array: ISBN10, ISBN13, Weight, Dimensions, and Current Price. This code must be written in PHP. An example URL is:
- Silvimass May 27, 2009
http://www.amazon.com/Biology-MasteringBiology-8th-Neil-Campbell/dp/0321543254/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1233281929&sr=8-1
My Answer: it's really easy. Check for the values into actual page and then just truncate string accordingly| Report Duplicate | Flag | PURGE
Amazon Web Developer PHP - 0of 0 votes
AnswersWrite a basic web application, following the Model-View-Controller/Modular design pattern. The following URLs should be functional:
- Silvimass May 27, 2009
• http://www.server.com/index.php?page=showTime - Displays the current system time.
• http://www.server.com/index.php?page=showDate - Displays the current system date.
• http://www.server.com/index.php?page=showVersion - Displays the current PHP / Java version.
Each page should be represented by an individual class. Any of the following languages can be used: PHP| Report Duplicate | Flag | PURGE
Amazon Web Developer PHP Object Oriented Design