[{"id":"phpbeginner-001","courseId":"php-beginner","domain":"types-and-operators","topic":"Integer type","prompt":"On a 64-bit PHP build the largest int is 9223372036854775807. What does the second line print?","hint":"Think about what happens to a whole number that is bigger than the int range.","explain":"Every int has a largest value on a given platform. A whole-number literal past that limit is still a number, so PHP must store it in some other numeric type.","source":"https://www.php.net/manual/en/language.types.integer.php","interaction":{"type":"single"},"options":[{"id":"a","text":"float(9.2233720368548E+18)","why":"Too large for an int, the literal is read as a float, which var_dump shows in scientific notation."},{"id":"b","text":"int(9223372036854775807)","whyNot":"Capping to the maximum happens when a too-large string is cast to int, not when a literal is written."},{"id":"c","text":"int(-9223372036854775808)","whyNot":"The wrap to a negative number only appears when an overflowed float is cast to int with (int)."},{"id":"d","text":"Parse error: integer literal out of range","whyNot":"A big whole number is valid PHP code; it simply becomes a float."}],"answer":"a","explanation":"A whole-number literal above the int maximum (9223372036854775807 on 64-bit) is read as a float, not capped to the maximum int.","concept":"A whole-number literal above the int maximum (9223372036854775807 on 64-bit) is read as a float, not capped to the maximum int.","rev":1,"updatedAt":"2026-10-24","kind":"scenario","code":"var_dump(9223372036854775807);\nvar_dump(9223372036854775808);","takeaways":["A whole number too big for int becomes a float, so do not assume it stays an exact integer."]},{"id":"phpbeginner-002","courseId":"php-beginner","domain":"types-and-operators","topic":"Float type","prompt":"A form field holds the text abc, and the code casts it to a float. What does this print?","hint":"Look at what a float cast does with text that does not start with a number.","explain":"A float is a number that can carry a decimal part. Casting text to float reads a number from the text, so what the text contains decides the result.","source":"https://www.php.net/manual/en/language.types.float.php","interaction":{"type":"single"},"options":[{"id":"a","text":"float(0)","why":"Text that is neither numeric nor leading numeric is converted to zero when cast to float."},{"id":"b","text":"float(3)","whyNot":"The cast does not count characters; it reads a number from the text, and 'abc' holds none."},{"id":"c","text":"float(NAN)","whyNot":"NAN is what some undefined numeric operations return, but a cast of plain text gives zero instead."},{"id":"d","text":"Fatal error: cannot cast string to float","whyNot":"A cast of text to float does not stop the script; unreadable text simply becomes zero."}],"answer":"a","explanation":"A string that is neither numeric nor leading numeric converts to zero when cast to float, so (float) \"abc\" gives zero.","concept":"A string that is neither numeric nor leading numeric converts to zero when cast to float, so (float) \"abc\" gives zero.","rev":1,"updatedAt":"2026-10-24","kind":"scenario","code":"var_dump((float) \"abc\");","takeaways":["Casting non-numeric text to float gives 0, so check input before trusting a float value."]},{"id":"phpbeginner-003","courseId":"php-beginner","domain":"types-and-operators","topic":"Boolean values and falsy values","prompt":"Which TWO of these statements about casting values to bool with (bool) are true?","hint":"Check each cast on its own; the result depends on the value's type and contents.","explain":"Casting with (bool) turns any value into true or false. The result depends on the type of the value and, for arrays and strings, on what it holds. Judge each cast separately.","source":"https://www.php.net/manual/en/language.types.boolean.php","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"(bool) array() is false","why":"An empty array casts to false; the manual's example shows var_dump((bool) array()) giving bool(false)."},{"id":"b","text":"(bool) 'false' is true","why":"The manual's example shows the text 'false' casting to bool(true), because it is a non-empty string."},{"id":"c","text":"(bool) -2 is false","whyNot":"The manual's example shows (bool) -2 giving bool(true), so a negative number casts to true."},{"id":"d","text":"(bool) 'foo' is false","whyNot":"The string 'foo' has content, and the manual's example shows it casting to bool(true)."},{"id":"e","text":"(bool) array(12) is false","whyNot":"The manual's example shows an array that holds an element, array(12), casting to bool(true)."},{"id":"f","text":"(bool) 2.3e5 is false","whyNot":"The manual's example shows the float 2.3e5 casting to bool(true)."}],"answer":"ab","explanation":"Casting to bool gives false for an empty array, but true for the string 'foo', the text 'false', a negative number and the float 2.3e5.","concept":"Casting to bool gives false for an empty array, but true for the string 'foo', the text 'false', a negative number and the float 2.3e5.","rev":1,"updatedAt":"2026-10-24","kind":"scenario","takeaways":["An empty array casts to false, but the text 'false' casts to true."]},{"id":"phpbeginner-004","courseId":"php-beginner","domain":"types-and-operators","topic":"NULL value","prompt":"In PHP 8.0 and later, writing (unset) $count is a valid way to turn $count into null.","hint":"Check which PHP versions still support an older casting syntax.","explain":"Null is the one value meaning no value, and an unset variable reads as null. Language features can be deprecated and later removed, so the version you target matters.","source":"https://www.php.net/manual/en/language.types.null.php","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"The cast existed in earlier versions, but PHP 8.0.0 removed it, so it no longer works there."},{"id":"b","text":"False","why":"(unset) was deprecated in PHP 7.2.0 and removed in PHP 8.0.0, so it cannot make a variable null in 8.0 and later."}],"answer":"b","explanation":"The (unset) cast was deprecated in PHP 7.2.0 and removed in PHP 8.0.0; an unset variable reads as null, which is a different thing.","concept":"The (unset) cast was deprecated in PHP 7.2.0 and removed in PHP 8.0.0; an unset variable reads as null, which is a different thing.","rev":1,"updatedAt":"2026-10-24","kind":"scenario","code":"$count = 5;\n$count = (unset) $count;","takeaways":["Old tutorials may show (unset) casts; check the PHP version before copying them."]},{"id":"phpbeginner-005","courseId":"php-beginner","domain":"types-and-operators","topic":"Single vs double quoted strings","prompt":"Put these parts of a heredoc string literal in the order they appear in the source code.","hint":"A heredoc uses a label to mark its boundaries; think about where each part sits relative to the text.","explain":"A heredoc is a third way to write a string literal. Instead of quotes, it uses a label that marks where the text begins and where it ends, and the label follows PHP's naming rules.","source":"https://www.php.net/manual/en/language.types.string.php","interaction":{"type":"sort","items":[{"text":"The <<< operator","why":"It starts the heredoc, and the label is given right after it."},{"text":"An identifier, such as EOT","why":"It names the label, provided right after the operator and before the line break."},{"text":"A newline","why":"It ends the opening line, so the text starts on the next line."},{"text":"The string text","why":"This is the body of the string, which follows the newline."},{"text":"The same identifier again","why":"It closes the string, and it must match the opening identifier."}]},"options":[],"answer":"o:abcde","explanation":"A heredoc opens with <<< and an identifier, then a newline, the string body, and the same identifier to close it.","concept":"A heredoc opens with <<< and an identifier, then a newline, the string body, and the same identifier to close it.","rev":1,"updatedAt":"2026-10-24","kind":"scenario","takeaways":["From PHP 7.3 the closing identifier may be indented; before that it had to start in column one."]}]