Php-mysql Course

The splat operator was introduced in PHP starting with version 5.6, so, to can use it and test the examples from this page, you need PHP 5.6+.
The Splat Operator is represented by three dots (...), and can be used to define functions that can be called with a variable number of arguments.

1. This operator can be used when the function is called, before an array argument.
<?php
function add($a, $b, $c) {
  return $a + $b + $c;
}

$arguments = [8, 9];     // array with values for $b and $c parameters
echo add(5, ...$arguments);      // 22
?>
2. The splat operator can also be used when the function is defined, before a parameter that represents an array of arguments.
<?php
// $params is an array containing the remaining arguments
function add($opt = 0, ...$params) {
  $sum = $opt + array_sum($params);
  echo '$opt is '. $opt .' / $params contains '. count($params .' arguments / $sum = '. $sum;    
}

add();             // $opt is 0 / $params contains 0 arguments / $sum = 0
add(1);            // $opt is 1 / $params contains 0 arguments / $sum = 1
add(5, 6);         // $opt is 5 / $params contains 1 arguments / $sum = 11
add(5, 6, 7);      // $opt is 5 / $params contains 2 arguments / $sum = 18
add(5, 6, 7, 8);   // $opt is 5 / $params contains 3 arguments / $sum = 26
?>

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
Splat Operator in PHP

Last accessed pages

  1. A simple script ActionScript 3 (4329)
  2. Read Excel file data in PHP - PhpExcelReader (96689)
  3. Register and show online users and visitors (39376)
  4. AJAX Course, free Lessons (19760)
  5. Sending data with GET and POST in the same request (7982)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (250)
  2. Read Excel file data in PHP - PhpExcelReader (90)
  3. PHP Unzipper - Extract Zip, Rar Archives (75)
  4. The Four Agreements (73)
  5. The Mastery of Love (66)