Skip to content

Instantly share code, notes, and snippets.

@DimitarChristoff
Created August 15, 2011 10:15
Show Gist options
  • Save DimitarChristoff/1146003 to your computer and use it in GitHub Desktop.
Save DimitarChristoff/1146003 to your computer and use it in GitHub Desktop.
web dev test
1. Which of the following will not add john to the users array?
array_add($users,'john');
array_push($users,'john');
$users[] = 'john';
$users ||= 'john';
2. What’s the difference between sort(), asort() and ksort()? Under what circumstances would you use each of these?
3.0 What would the following code print to the browser in PHP? Why?
$num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num;
3.1 What would the following code alert in javascript? Explain variable scope / scope chain.
var num = 10;
alert((function(num){
var foo = bar = num = 30;
return num;
})(20));
alert(num);
alert(bar);
alert(foo);
3.2 What are hoisting and block scope in javascript? What will the following code do?
var foo = 1;
(function() {
if (!foo) {
var foo = 10;
}
alert(foo);
})();
3.3 In Javascript, what will the value of this.foo be at the end? What will `this` refer to?
var foo = 20, bar = 30;
(function() {
for (foo = 0; foo <= bar; ++foo) {
console.log(foo);
}
})();
alert(this.foo);
3.4 Is there anything wrong with this logic? If so, how would you fix it?
var list = document.getElementsByTagName('TD');
for (var i=0; i < list.length; i++) {
list[i].onclick = function() { alert(i) }
}
4. How do you do variable variables in PHP and in Javascript?
5. What is the difference between a reference and a regular variable? How do you pass by reference & why would you want to?
6. What functions can you use to add library code to the currently running script?
7. What is the difference between foo() & @foo()?
8. How do you debug and test a PHP and a Web application?
9. What does === do? What’s an example of something that will give true for ‘==’, but not ‘===’?
10. How would you declare a class named “myclass” ? with no methods or properties?
11. How would you create an object, which is an instance of ‘“myclass’??
12. How do you access and set properties of a class from within the class?
13. What is the difference between include & include_once? include & require?
14. What function would you use to redirect the browser to a new page?
1. redir()
2. header()
3. location()
4. redirect()
15. What function(s) can you use to open a file for reading and writing?
1. fget();
2. file_open();
3. fopen();
4. open_file();
5. file_get_contents();
16. What’s the difference between mysql_fetch_row() and mysql_fetch_array()?
17. Given a line of text $string, how would you strip all the HTML tags from it (function / string methods or regex)?
18. Explain the different protocols (GET, POST, REQUEST, COOKIE and SESSION collections, CURL). How would you fetch
a remote page given conservative security restrictions on fopen?
19. What does the GD library do?
20. Name a few ways to output (print) a block of HTML code in PHP?
21. What are SQL injections and how do you deal with them?
22. In any language or pseudo code, please write a few lines to show how you solve the FizzBuzz game.
To clarify: children are given numbers between 1 and 100. if a number they hear is divisible by 3, they say
'fizz'. if it is divisible by 5, they say buzz. if it's divisible by both, they say 'FizzBuzz'. Eg, 10 results in
'buzz', 15 results in 'FizzBuzz'. Don't take more than 10-15 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment