SóProvas


ID
1599697
Banca
FUNRIO
Órgão
UFRB
Ano
2015
Provas
Disciplina
Programação
Assuntos

Considere o segmento de código escrito em PHP 4:

                     Número da linha         Segmento de código
                                   1                                    $i = 10;
                                   2                               $i = (string) $i;
                                   3                              $i = (integer) $i; 


Marque a alternativa correta.

Alternativas
Comentários
  • PHP possui "implicit casting" (conversão de tipos implícita), também chamado de "type juggling" e apesar de ser uma linguagem de tipagem fraca (tipo da variável pode ser alterado de acordo com as operações) e dinâmica (não há necessidade de declaração prévia do tipo da variável) é possível fazer a conversão explícita de tipos.


    "Casting Operators
    Although PHP is a weakly typed language, there are occasions when it’s useful to consider a value as a specific type. The casting operators, (int), (float), (string), (bool), (array), and (object), allow you to force a value into a particular type. To use a casting operator, put the operator to the left of the operand. Table 2-8 lists the casting operators, synonymous operands, and the type to which the operator changes the value."


    fonte: "Programming PHP", Rasmus Lerdorf & Kevin Tatroe, O'Reilly, 2002


    Gabarito: A