Andrew Hartley2,750 Points
Why is foreach not considered a PHP function? Is an array function considered different from a function like count?
Questioning the quiz question "Which of the following is not a PHP function?"
count, isset, and date are PHP functions, but foreach is not? An array function is not a function? I am totally confused by this question. Can anybody enlighten me?
Jennifer NordellTreehouse Teacher
Hi there! I'm not exactly sure what you mean by an
array function. However,
foreach is a loop which is considered a language construct much the same way an if/else statement is considered a construct. That being said, I'm also given to understand that technically speaking
$isset() is also a language construct and not a function. I will check up on that, though
The idea here is that some things are hard-coded into the language and some were added by other programmers to become part of the language. They are considered to be constructs.
Hope this helps!