Android,iOS,Gadgets,Reviews Everything About Technology

- Advertisement -

22 most common questions in job interviews for a web developer

52

- Advertisement -

Qualitative training is one of the key elements necessary for successful interviews, which, by the way, are often neglected.

Despite the fact that this article does not pretend to be objective, it includes all the main questions that can be asked about PHP, JS, JQuery, CSS, HTML, MySQL and OOP, as well as detailed answers to them.

Having studied these topics, you will noticeably improve your theoretical base and significantly increase your chances of obtaining a cherished work.


- Advertisement -

– How many data types are in PHP?

PHP supports 8 basic data types.

4 scalar types:

– boolean. A boolean data type, variables of this type can be either true or false.

– integer. Integer data type, variables can take integer values ​​(… -2, -1, 0, 1, 2 …) in the range from -2 ^ 31 to + 2 ^ 31. If the value exceeds this threshold, it is automatically converted to the float type.

– float. A numeric data type with a floating point can contain both integer and fractional values.

– string. String data type. Contains an unlimited number of different characters. PHP does not impose any restrictions on the length of the string, so you can safely work even with VERY large strings.

2 complex (composite) types:

– array. An array contains an ordered list of elements.

– object. An object that contains an object (an instance of a class).

2 special types:

– resource. Reference to an abstract element, the so-called. external resource. Examples of external resources – a link to the file and a link to the result of the query.

– NULL. An empty data type denoting the absence of any value. Such values ​​are usually said to be “undefined”. An empty value can initialize variables of any other type.


– What is a static function and how does it differ from “normal” (not static)?

Static belongs to the class, not the instance of the class. And it is called by the class, and not by the object, i.e. directly. Declaring the properties and methods of the class static allows you to access them without creating an instance of the class. The attribute of a class declared static can not be accessed by an instance of the class (but a static method can be called). Because static methods are called without instantiating the class, the pseudo variable is $thisnot available within the method declared static. Access to the static properties of a class can not be obtained through an operator ->.


– Is there a difference between single and double quotes in PHP?

In double quotes, the data is “parsed”, and in single quotes there is not. With double quotes in this case will be displayed Chimay, and for single –  quotes  $beer.

$beer = 'Chimay';
echo "$beer";

– Write a program that prints out prime numbers, i.e. dividing up without a remnant only for themselves and for 1.

$lst = array();
$k = "prime";

for ($i = 2; $i < 100; $i++) {
    for ($j = 2; $j < $i; $j++) {
        if (($i % $j) == 0) {
            $k = "not prime";
    }
}

if ($k == "prime") $lst[] = $i;
else $k = "prime";
}

foreach($lst as $list) echo $list . "";

– Write a censor program that would replace the words “fuck”, “idiot” and “bitch” with “f ** k”, “id ** t” and “bi ** h”, entered by the user into the form.

$find = array(
    ‘fuck’,
    ‘idiot’,
    ‘bitch’
);
$replace = array(
   ‘f * *k’,
   ‘id * *t’,
   ‘bi * *h’
);
If (isset($_POST[‘user_input’]) && !empty($_POST[‘user_input’])) {
    $user_input = $_POST[‘user_input’];
    $user_input_new = str_ireplace($find, $replace, $user_input);
    echo $user_input_new;
}

– What are dynamic variables?

A dynamic variable is one whose name is stored in the variable itself. This is the so-called “variable variable”. For example:

$var = "first";
$$var = "Second";
// $$var == $first == "Second"

$$var– Dynamic, its name can change along with the change $var. You can also associate a variable name with the contents of another variable implicitly:

$first = "second";
$second = "third";
print $first; // напечатает "second"
print $$first; // напечатает "third"

– What are design patterns?

The design pattern is a general typical solution to a problem that is repeated many times during the design process of the software architecture. They show the relationships and interactions between classes, make the system flexible and easily changeable. Due to their correct use, the utilization rate of ready solutions is increased.


– Write an example of the implementation of polymorphism.

Class One
{
    function foo()
    {
        echo “Hellofromclass One!;
    }

    function callMe()
    {
        $this->foo();
    }
}

Class Two extends One
{
    function foo()
    {
         echo “Hellofromclass Two”;

    }
}

$Two = new two();
$Two->callMe();

 – What other paradigms (models, approaches) programming other than OOP?

Of those that are most common: functional, aspect-oriented and procedural.


– It is necessary to output a message with an alert, 3 seconds after the script is started. How to do it?

So:

setTimeout(alert(“Hello”), 3000);

Or so:

setTimeout(function() {alert(“Hello”)}, 3000);

– Tell us a few words about objects in JavaScript

Objects (they are associative arrays, hashes) and work with them in JavaScript are not implemented in the same way as in most languages. An object in JavaScript is a normal associative array or, in other words, a “hash”. It stores any matching “key => value” and has several standard methods.


- Advertisement -

– There are two functions. Is there a difference between them? If so, which one?

function f(a,b) { return a+b }

and

var f = function(a,b) { return a+b }

The difference is – it lies in the visibility of the function. The variant of the function is not varvisible anywhere in the current scope. Including the very definition of the function. Variant c varassigns a function to a variable, so this function is visible only after the definition.


– What will the code do: break me_baby; ?

Exits the current block of the loop or switch to the label “me_baby”.


– What is SQL injection?

SQL injection – the embedding of malicious code into queries to the database. Using SQL injections, an attacker can not only get private information from a database, but also, under certain conditions, make changes there. Vulnerability to SQL injection results from the fact that user information enters a query to the database without proper processing: to ensure that the script is not vulnerable, you need to make sure that all user data falls into all requests to the database in a screened form.


– Let’s say you have an online store. Make a request that will show how much money each individual customer has brought in total for the entire time of the store’s existence.

SELECT customer_name, SUM(order_price)
FROM orders
GROUP BY customer_name;

– What is the difference between writing #my and .my?

#my – selector ID.

.my Class selector.


– What are pseudo-classes?

Pseudo-classes are what are usually written after the selector through a colon to determine the response or state for a given selector. The most famous pseudo-classes are: link,: hover,: visited and: active. Pseudo-classes have the following structure:

selector:pseudo class {
    property: value;
}

those. you just need to put a colon between the selector and the pseudo-class.

a.snowman:link {
    color: blue;
}
a.snowman:visited {
    color: purple;
}
a.snowman:active {
    color: red;
}
a.snowman:hover {
    text-decoration: none;
    color: blue;
    background-color: yellow;
}

– Find all div elements with class one, as well as all p elements with class two, then add them all to class three and visually smoothly lower them down.

$(“div.one”).add(“p.two”).addClass(“three”).slideDown(“slow”);

– Select divs that do not have cls

$(‘div:not(.cls));

 – What is DOCTYPE and why is it needed?

DOCTYPE is a Document Type Definition (DTD), the rules by which a particular document (web page) of XML or (X) HTML is validated. With this entry, the browser determines which version of the DTD is used in this document. And it is necessary for the browser to correctly display the markup of the document. If no DOCTYPE is specified, the browser will add a “gag”, and each browser will add its “gag”. As a result, there is no question of any cross-browser compatibility.


– What are entities?

Entities are combinations of a & sign and an alphabetic or numeric code after it, intended to replace characters that can not occur in a “clean” form in HTML text, such as the “<” symbol.


“What magical methods do you know?” What is this?

These are methods reserved in php, which begin with a double underscore “__”.

List of all magic methods:

  • __construct
  • __destruct
  • __call
  • __callStatic
  • __get
  • __set
  • __isset
  • __unset
  • __sleep
  • __wakeup
  • __toString
  • __set_state
  • __clone

__construct and __destruct are the most popular methods that implement the basic concepts of object-oriented programming: the constructor and the destructor;

__call, __callStatic, __get and __set – methods associated with reloading calls to both properties
and methods. The __get () and __set () methods are called when setting and retrieving a property value,
and the __call () and __callStatic methods are called when the method is called. It is worth noting that these magic functions
will be called only and exclusively if the requested method or property
does not exist;

__isset – a method that works when calling the functions empty () or isset () on a non-existent
or inaccessible property of the class;

__unset – triggered when the unset () function is called on a non-existent or inaccessible property of the class;

__sleep and __wakeup are methods that are called only from the serialize and unserialize functions, respectively
. The __sleep method will be called immediately when the function is serialize applied to the object, and
the __wakeup method – when applying unserialize. Currently, methods are used to save the current state of the system and then restore this state
(for example, connect to the database);

__toString is a method by which you can refer to a class as a string (for example,
using print or echo);

__set_state is a method that is called for classes exporting property values ​​with the
var_export () function ;

__clone – is called when the object is cloned (introduced for use because
objects in php5 and higher are passed by reference);

__invoke – is called when trying to use an object as a function.

- Advertisement -

Comments