Yes, this is the cry of the soul. Because on average a week I will interview a few who claim to be a php programmer.
The cry of the soul, as follows:
of, say, 10 people, the simplest tests pass a maximum of two (one or half or two-thirds). Here is such a simple statistic.
Maybe I ask too complicated questions (somewhat modified questions under the cut)?
')
Actually, in this topic, I would suggest to talk about the tasks offered to a potential employee at the interview.
Maybe someone will share their tasks, or in the comments in some way something surprisingly simple will be born, but allowing one to understand the level of a person?
Task number one.
$ x = 1;
if ($ x == '1') {
echo 'a';
}
if ($ x == true) {
echo 'b';
}
if ((bool) $ x === true) {
echo 'e';
}
if ($ x === true) {
echo 'c';
}
if ((int) $ x === true) {
echo 'd';
}
/ *
What line will be displayed when executing the script?
Why is each condition being executed or not?
* /
Problem number two
/ *
Incoming string
site.ru/?x=foo* /
error_reporting (E_ALL);
ini_set ('display_errors', '1');
ini_set ('register_globals', 'on');
var_dump ($ x);
unset ($ x);
ini_set ('register_globals', 'off');
var_dump ($ x);
/ *
What will the script output in ideal server conditions?
* /
Problem number three
class Test {
private $ var;
function setMe ($ value) {
$ this-> var = $ value;
}
}
class More extends Test {
public $ var;
}
$ oTest = new Test;
$ oMore = new More;
echo $ oTest-> setMe ('foo');
echo $ oMore-> setMe ('foo');
echo $ oMore-> var;
echo $ oTest-> var;
/ *
For which PHP version will this script work?
What will this script output?
* /
Problem number four
/ *
Suppose the incoming URL is:
site.ru/?x=1Suppose we have a table of the form
--news
---- id (int, 11)
---- anons (varchar, 255)
---- text (text)
There are records
1 announcement text
2 Announcement1 Text2
* /
$ query = "SELECT anons, text FROM news WHERE id = '". $ _ GET [' x ']. "'" ";
$ res = mysql_query ($ query);
if ($ res && mysql_num_rows ($ res)> 0) {
while ($ row = mysql_fetch_assoc ($ res)) {
echo $ row ['anons'];
echo $ row ['text'];
}
}
/ *
Make a SQL injection script that displays all existing news.
Modify the query so that the SQL injection does not work.
Give the heading 404 Not Found in case news with the specified ID is not detected in the database.
* /