PHP - FunctionsWhy does PHP require parameters with default values to be placed after parameters without defaults?ATo avoid ambiguity when calling functions with missing arguments.BBecause PHP does not support default values at all.CTo force all parameters to have default values.DBecause parameters are always passed by reference.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand function call ambiguityIf default parameters came before required ones, PHP wouldn't know which argument matches which parameter when some are missing.Step 2: Recognize PHP's design choicePlacing defaults last ensures clear matching of arguments to parameters.Final Answer:To avoid ambiguity when calling functions with missing arguments. -> Option AQuick Check:Parameter order prevents call ambiguity [OK]Quick Trick: Defaults last prevent confusion in function calls [OK]Common Mistakes:Thinking PHP disallows default parametersBelieving all parameters must have defaultsConfusing parameter passing methods
Master "Functions" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Arrays - Array sort functions - Quiz 6medium Conditional Statements - If statement execution flow - Quiz 6medium Conditional Statements - Match expression (PHP 8) - Quiz 5medium Functions - Nullable types in functions - Quiz 4medium Loops - Continue statement with levels - Quiz 10hard Operators - Assignment and compound assignment - Quiz 13medium Operators - Null coalescing operator - Quiz 15hard PHP Basics and Execution Model - PHP tags and embedding in HTML - Quiz 12easy PHP Basics and Execution Model - What is PHP - Quiz 2easy PHP Basics and Execution Model - Comments in PHP - Quiz 3easy