$myarray[10] = "Dog";
$myarray[] = "Human";
$myarray[ myvalue ] = "Cat";
$myarray["Dog"] = "Cat";
print "The value is: ";
print $myarray[myvalue]." ";
?> - Ответ: A) The value is: Dog"> PHP Test online - 4. What is displayed when the following script is executed?<br><br><?php<br>define(myvalue, "10");<br>$myarray[10] = "Dog";<br>$myarray[] = "Human";<br>$myarray[ myvalue ] = "Cat";<br>$myarray["Dog"] = "Cat";<br>print "The value is: ";<br>print $myarray[myvalue]." ";<br>?> - Верный ответ: A) The value is: Dog

4. What is displayed when the following script is executed?

<?php
define(myvalue, "10");
$myarray[10] = "Dog";
$myarray[] = "Human";
$myarray[ myvalue ] = "Cat";
$myarray["Dog"] = "Cat";
print "The value is: ";
print $myarray[myvalue]." ";
?>


Вариант ответа 1 - A) The value is: Dog

Вариант ответа 2 - B) The value is: Cat

Вариант ответа 3 - C) The value is: Human

Вариант ответа 4 - D) The value is: 10

Вариант ответа 5 - E) Dog


Комментарий: The important thing to note here is that the $myarray array’s key value is being referenced without quotes around it. Because of this, the key being accessed is not the myvalue string but the value represented by the myvalue constant. Hence, it is equivalent to accessing $myarray[10], which is Dog, and Answer A is correct.

Комментарии

Имя пользователяТекст комментарияВведите код