Questions PHP

luffy78

luffy78 Le 24 septembre 2019 à 21:21

Bonjour,
pour un entretien je dois répondre à ces questions. J'aurais besoin d''un coup de main pour le faire. Pour le moment je galère à répondre à toutes les questions. Si vous pouvez m'aider merci.
Bonne journée

Voici les questions :




Question1:

Nameone value of a variable $x in PHP where empty($x) is true and
isset($x) is also true.




Question2:
Youhave a class called Student, defined as follows:
classStudent
{

   private$gpa;
   private$age;
   publicfunction __construct($gpa, $age)
   {
       $this->gpa= $gpa;
       $this->age= $age;
   }
   publicfunction getGPA()
    {

       return$this->gpa;
   }
   publicfunction getAge()
    {

       return$this->age;
   }
}


Youhave an array of student objects and you want to sort them by GPA
descending, then age ascending in case two students have the same
GPA.



Howwould you implement this in PHP?


Question3:


Auser clicks on a link, which directs them to a page with the
following url:

testpage.php?userid=100
Howwould you display the provided userid on the page?
Answer:
Question4:
Youare writing a class that communicated to the database
(DatabaseModel). In your application, you have many DatabaseModel
instances but they should all share a single connection.

Whattype of member variable would you use to store the single connection
within the DatabaseModel class? Hint: It has two qualifiers.



Answer:


Question5:

Nameone advantage and one disadvantage of adding an index to a table in
MySQL.

Answer:





Question6:


Forthe following html elements, define the css rules that add spacings
in between each span elements. Try to write it in a way that supports
older browsers as much as possible.

<div>
<span>Element1</span>
<span>Element2</span>
<span>Element3</span>
</div>


Answer:


Question7:


IfI have a image that I want it to be fit in the container but when the
container width is larger than the image width I don’t want the
image to be scaled larger than its actual size, what css rule should
I apply to that image?



Question8:


Ifyou’re writing a html template component that could be included
several times on a single page, and the component template has a
container named “component_a", would you assign “component_a”
as id or class, and why?



Question9:


Writea function called "count_digits" in javascript that takes
an integer and finds the number of each possible digit (i.e. 0s, 1s,
2s, 3s, etc) it has in it. The result should be an object whose
property names represent digits and properly values are the
corresponding counts
.


Question10:


Thefollowing code will insert 5 links to the DOM. The intention is when
you click on nth link, it alerts n. Is there anything wrong with the
code and why? How would you fix it?

for(vari = 0; i < 5; i++) {
link= document.createElement("a");
   link.innerHTML= "Link " + i;
   link.onclick= function () {
       alert(i);
   };
   document.body.appendChild(link);
}

Vous devez être connecté pour poster une réponse. Se connecter ou Créer un compte