Function arguments: an argument/argument list is a comma-delimited list of expressions that are listed in the parentheses after defining a function's name. */ function Hello($array) { if (is_array($array)) { foreach ($array as $names) { echo "Hello, {$names}", "</br>"; } } else { echo 'Hello, friends!'; } } $names = array('Jack', 'Steve', 'David'); Hello($names); /* Return functions: for storing a functions value and ending a function's exectution so that it can be called upon later. Function's default arguments: defining an arguments value within the confines of the parentheses, removing the need to define the variable later e.g. $trife. */ function hi($dude, $trife = 'trouble') { return "Sup {$dude}, I see you got into some {$trife}."; } $poo = hi('Eric'); echo $poo, "</br>"; function add_up($a, $b)
<?php Hello(); echo "\n";
?> </div> <div class="<?php echo getFieldErrorClass($validationErrors, 'password2'); ?> "> <label for="password2">Retype Password:</label> <input type="password" id="password2" name="password2" /> <?php echo formErrors(getValue($validationErrors, 'password2', [])); ?> </div> <div> <input type="submit" /> <div class="<?php echo Hello($validationErrors, 'username', 'password1', 'password2'); ?> "> <label for="hello">Hello, <?php echo $username; ?> </label> <br> </div> </div>
<?php function Hello($name) { echo "Привет, {$name}"; } //1 Hello('John'); //2 $func = 'Hello'; $func('John'); var_dump($x); //3 $x = function ($name) { echo "Привет, {$name}"; }; $x('John');
<?php function hello($name = "tundmatu kasutaja") { echo "hello " . $name; } $user = "******"; Hello($user); echo "<br>"; hello();