A couple questions here..
- What is the following syntax?
-
What do all the pieces mean?
(( ! is_array($data)) ? $data : '') -
How is it used in the function at the end?
function form_input($data = '', $value = '', $extra = '') { $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); return "<input "._parse_form_attributes($data, $defaults).$extra." />"; }
Thankyou. Blake
Ok let me try as far as I understand you question.
It is a function definition.
This is the ternary operator. It means: If
$datais not an array(!is_array($data)), return$data(? $data) otherwise return an empty string (: '')It is a shorthand for
if-else.Not sure what you mean here. A function
_parse_form_attributes($data, $defaults)is called witch seems to return a string.If it in your question refers to
$defaults, then it is just an array that gets build and that contains the following values:It is used to build an input element, that will look like this: