Soru 1: What is the best way to explain what this script does?
if (!$_SESSION['myusername'])
{
header('locaton: /login.php');
exit;
}
- This script times out the session for myusername.
- This script is on a page that requires the user to be logged in. It checks to see if the user has a valid session.
- Cookies are starting to be stored as a result of this script.
- This script validates the username and password.
Soru 2: Which operator would you use to find the remainder after division?
- /
- %
- //
- DIV
Soru 3: What is the purpose of adding a lowercase “u” as a modifier after the final delimiter in a Perl-compatible regular expression?
- It makes the dot metacharacter match anything, including newline characters.
- It makes the pattern match uppercase letters.
- It inverts the greediness of the quantifiers in the pattern so they are not greedy by default.
- Both the pattern and subject string are treated as UTF-8.
Soru 4: What is the value of $total in this calculation?
$total = 2 + 5 * 20 - 6 / 3
- 44
- 138
- 126
- 100
Soru 5: Which value equates to true?
- 0
- NULL
- -1
- ”
Soru 6: What is a key difference between GET and POST?
- GET is used with the HTTP protocol. POST is used with HTTPS.
- GET displays the submitted data as part of the URL. During POST, this information is not shown, as it’s encoded in the request body.
- GET is intended for changing the server state and it carries more data than POST.
- GET is more secure than POST and should be used for sensitive information.
Soru 7: Which are valid PHP error handling keywords?
- try, throw, catch, callable
- try, throw, catch, finally
- try, yield, catch, finally
- yield, throw, catch, finally
Soru 8: The _ operator is useful for sorting operations. It compares two values and returns an integer less than, equal to, or greater than 0 depending on whether on whether the value on the ___is less than, equal to, or greater than the other.
- greater-than; right
- equality; right
- spaceship; left
- comparison; left
Soru 9: In the following script, which line(s) will cause an error(s)?
<?php
$count = 0
$_xval = 5
$_yval = 1.0
$some_string = "Hello there!";
$some_string = "How are you?";
$will i work = 6;
$3blindmice = 3;
?>
- Line 6 will cause an error because you can’t reassign a new value to a variable that has already been set.
- Line 5 will cause an error because some_string should be someString.
- Line 3 and 4 will cause an error because a variable cannot start with an underscore(_).
- Line 7 and 8 will cause an error. Line 7 has whitespace in $will i work and should be $will_i_work. Line 8 cannot start with a number befcause it is a variable.
Soru 10: What does this script do?
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
if ($email === false) {
$emailErr = "Please re-enter valid email";
}
- It makes sure the email address is a good and functioning address
- It makes an email safe to input into a database
- It assigns an email to a variable and then removes all illegal characters from the $email variable
- It verifies that an email address is well formed.
Soru 11: Which code snippet uses the correct syntax for creating an instance of the Pet class?
- $dog = new Pet;
- $horse = (new Pet);
- $cat = new Pet();
- All of these answers
Soru 12: Which is the correct format for adding a comment to a PHP script?
- #This is a comment
- /* This is a comment /*
- // This is a comment
- All of these answers
Soru 13: What is missing from this code, which is supposed to create a test cookies?
1 $string_name = " testcookie";
2 $string_value = "This is a test cookie";
3 $expiry_info = info()+259200;
4 $string_domain = "localhost.localdomain";
- The $_REQUEST is missing.
- The call to setcookie() is missing.
- The $_COOKIES array is missing.
- The cookie session is missing.
Soru 14: All variables in PHP start with which symbol?
- &
- %
- _
- $
Soru 15: In a conditional statement, you want to execute the code only if both value are true. Which comparison operator should you use?
- ||
- &&
- &
- <=>