Prueba para programadores php Metamorf

Recuerde tomar el test una sola vez y una vez que haya iniciado el test completarlo al 100% porque el Sistema grabará sus resultados si cierra el test antes de finalizar y si toma el test más de 2 veces será automáticamente descalificado.

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]."\n";
?>
The value is: Dog
The value is: Cat
The value is: Human
The value is: 10
Dog

Which values should be assigned to the variables $a, $b and $c in order for the followingscript to display the string Hello, World!?

<?php
    $string = "Hello, World!";
    $a = ?;
    $b = ?;
    $c = ?;
    if($a) {
        if($b && !$c) {
            echo "Goodbye Cruel World!";
        } else if(!$b && !$c) {
            echo "Nothing here";
        }
    } else {
        if(!$b) {
            if(!$a && (!$b && $c)) {
                echo "Hello, World!";
            } else {
                echo "Goodbye World!";
            }
        } else {
            echo "Not quite.";
        }
    }
?>
False, True, False
True, True, False
False, True, True
False, False, True
True, True, True

What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?

<?php
    $myarray = ["My String",
                       "Another String",
                       "Hi, Mom!"];
?>
Using a for loop
Using a foreach loop
Using a while loop
Using a do...while loop
There is no way to accomplish this goal

Consider the following segment of code:

<?php
    define("STOP_AT", 1024);
    $result = array();
    /* Missing code */ {
        $result[] = $idx;
    }
    print_r($result);
?>

What should go in the marked segment to produce the following array output?

Array { [0] => 1
            [1] => 2
            [2] => 4
            [3] => 8
            [4] => 16
            [5] => 32
            [6] => 64
            [7] => 128
            [8] => 256
            [9] => 512 }
Foreach($result as $key => $val)
While($idx *= 2)
For($idx = 1; $idx < STOP_AT; $idx *= 2)
For($idx *= 2; STOP_AT >= $idx; $idx = 0)
While($idx < STOP_AT) do $idx *= 2

How does the identity operator === compare two values?

It converts them to a common compatible data type and then compares the resulting values
It returns True only if they are both of the same type and value
If the two values are strings, it performs a lexical comparison
It bases its comparison on the C strcmp function exclusively
It converts both values to strings and compares them

At the end of the execution of the following script, which values will be stored in the $a->my_value array? (Choose 3)

<?php
    class my_class {    
        public $my_value = array();    
        function __construct ($value)    
        {        
            $this->my_value[] = $value;    
        }    
        function set_value ($value)    
        {        
            $this->$my_value = $value;    
        }
    }
    $a = new my_class('a');
    $a->my_value[] = 'b';
    $a->set_value ('c');
    $a->my_class('d');
?>
C
B
A
D
E

How can you write a class so that some of its properties cannot be accessed from outside its methods?

By declaring the class as private
By declaring the methods as private
It cannot be done
By writing a property overloading method
By declaring the property as private

How can the index.php script access the email form element of the following HTML form? (Choose 2)

<form action="index.php" method="post">    
    <input type="text" name="email"/>
</form>
$_GET['email']
$_POST['email']
$_SESSION['text’]
$_REQUEST['email']
$_POST['text']

What will the $array array contain at the end of the execution of the following script?

<?php    
    $array = array ('1', '1');    
    foreach ($array as $k => $v) {        
        $v = 2;    
    }
?>
Array ('2', '2')
Array ('1', '1')
Array (2, 2)
Array (Null, Null)
Array (1, 1)

Look at the code. What one word is method XXXXX, in order to select all users with IDs 1-4 and to select only 'name' column?

$users = User::XXXXX([1,2,3,4], ['name']);
Where
Find
Has
Search

Look at the code. One author has many books, and one book may have many ratings. So what should be behind XXXXXX, if you want to get the authors with at least one rating for their book?

$authors = Author::XXXXXX('books.ratings')->get();
Where
Find
Has
Have

Look at the code. What parameter should be instead of X, so that command would generate a migration, factory, and resource controller for the model?

php artisan make:model book -X
A
Mf
D
R

Look at the code, we want to get the articles with title longer than 40 characters. What's behind XXXXXX? (the answer is one word)

$articles = Article::all()->XXXXXX(function($article) {
    return strlen($article->title) > 40;
});
Find
Where
Filter
Extract

Look at the code. What is the database table name that this model will work with, if you don't make any more changes in the model?

php artisan make:model Person
Person
Persons
People
Users

Look at the code. You want to have countries with many states, and states with many cities. And then you want to get all cities by certain countries. What's the word behind XXXXXX?

 
// Controller code
$countries = Country::with('cities')->get();

// Model code
class Country extends Model
{
    public function cities()
    {
        return $this->XXXXXX(City::class, State::class);
    }
}
HasMany
BelongTo
BelongsToMany
HasManyThrough

Look at the code snippet. Those two blocks will perform an identical check/action. What's behind XXXXXX?

 
@if (!Auth::check())
    Please log in.
@endif

@XXXXXX (Auth::check())
    Please log in.
@endXXXXXX
Unless
Ifnot
Notif
Else

If you put a Blade file inside a subfolder, like "resources/views/products/create.blade.php", how do you call it from Controller?

View('products.create')
View('products-create')
View('products/create')
View('products_create')

The command "php artisan make:controller PhotoController --resource" will create Controller class with how many methods?

4
6
7
None

Let's say that Eloquent has relationships: Authors hasMany Books, and Books hasMany Chapters. What is the Eloquent sentence to get authors with at least one book and with at least one chapter?

Author::has('books.chapters')->get();
Author::whereExists('books', 'chapters')->get();
Author::whereHas(['books', 'chapters'])->get();
Author::get('books.chapters');

What is Laravel Artisan command to delete all the DB tables and run migrations again from scratch?

Php artisan migrate:seed
Php artisan migrate:fresh
Php artisan migrate:rollback
Php artisan migrate --force
{"name":"Prueba para programadores php Metamorf Recuerde tomar el test una sola vez y una vez que haya iniciado el test completarlo al 100% porque el Sistema grabará sus resultados si cierra el test antes de finalizar y si toma el test más de 2 veces será automáticamente descalificado.", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is displayed when the following script is executed?   , Which values should be assigned to the variables $a, $b and $c in order for the followingscript to display the string Hello, World!?   , What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?  ","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker