} } function lengthStringAndUpperCase($string) { $length = strlen($string); $uppercase = strtoupper($string); $arrayToReturn = array($uppercase, $length); return $arrayToReturn; } $som = berekenSom(5, 4); $vermenigvuldeging = vermenigvuldig(5, 4); $getalToCheck = 13; $isGetalEven = ""; $stringToUpperAndCount = "sepperenty"; $stringToUpperAndLength = lengthStringAndUpperCase($stringToUpperAndCount); if (isEven($getalToCheck)) { $isGetalEven = "het getal " . $getalToCheck . " is even"; } else { $isGetalEven = "het getal " . $getalToCheck . " is oneven"; } ?> <!doctype html> <html> <head> <title>
/** * Overrides theme_pager(). */ function typebased_pager($variables) { // Make pager look and behave like on most blogs and community websites $tags = $variables['tags']; $element = $variables['element']; $parameters = $variables['parameters']; $pager_width = theme_get_setting('trim_pager'); global $pager_page_array, $pager_total; $li_previous = theme('pager_previous', array('text' => isset($tags[1]) ? $tags[1] : t('‹ previous'), 'element' => $element, 'interval' => 1, 'parameters' => $parameters)); $li_next = theme('pager_next', array('text' => isset($tags[3]) ? $tags[3] : t('next ›'), 'element' => $element, 'interval' => 1, 'parameters' => $parameters)); $total_number_of_pages = $pager_total[$element]; $current_page_number = $pager_page_array[$element] + 1; /* If there is just one page we don't need a pager. */ if ($total_number_of_pages <= 1) { return; } /* Elipsis does not make sense if there is just one page more than the pager width. */ if ($total_number_of_pages - $pager_width == 1) { $pager_width++; } /* Genarate pager without any elipsis */ if ($total_number_of_pages <= $pager_width) { if ($li_previous) { $items[] = array('class' => array('pager-previous'), 'data' => $li_previous); } for ($i = 1; $i <= $total_number_of_pages; $i++) { if ($i < $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => $current_page_number - $i, 'parameters' => $parameters))); } if ($i == $current_page_number) { $items[] = array('class' => array('pager-current'), 'data' => $i); } if ($i > $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => $i - $current_page_number, 'parameters' => $parameters))); } } if ($li_next) { $items[] = array('class' => array('pager-next'), 'data' => $li_next); } } /* Genarate pager with elipsis */ if ($total_number_of_pages > $pager_width) { /* Genarate pager with elpisis on right side. */ if ($current_page_number < $pager_width) { if ($li_previous) { $items[] = array('class' => array('pager-previous'), 'data' => $li_previous); } for ($i = 1; $i <= $pager_width; $i++) { if ($i < $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => $current_page_number - $i, 'parameters' => $parameters))); } if ($i == $current_page_number) { $items[] = array('class' => array('pager-item pager-current'), 'data' => $i); } if ($i > $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => $i - $current_page_number, 'parameters' => $parameters))); } } $items[] = array('class' => array('pager-ellipsis'), 'data' => '…'); $items[] = array('class' => array('pager-item'), 'data' => theme('pager_last', array('text' => $total_number_of_pages, 'element' => $element, 'interval' => 1, 'parameters' => $parameters))); $items[] = array('class' => array('pager-next'), 'data' => $li_next); } /* Genarate pager with elpisis on both sides. */ if ($current_page_number >= $pager_width && $current_page_number <= $total_number_of_pages - $pager_width + 1) { if ($li_previous) { $items[] = array('class' => array('pager-previous'), 'data' => $li_previous); } $items[] = array('class' => array('pager-item'), 'data' => theme('pager_first', array('text' => "1", 'element' => $element, 'interval' => 1, 'parameters' => $parameters))); $items[] = array('class' => array('pager-ellipsis'), 'data' => '…'); function isEven($num) { return $num % 2 ? TRUE : FALSE; } if (isEven($pager_width) == TRUE) { $a = floor($pager_width / 2); } if (isEven($pager_width) == FALSE) { $a = floor($pager_width / 2) - 1; } for ($i = $current_page_number - $a; $i <= $current_page_number + floor($pager_width / 2); $i++) { if ($i < $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => $current_page_number - $i, 'parameters' => $parameters))); } if ($i == $current_page_number) { $items[] = array('class' => array('pager-current'), 'data' => $i); } if ($i > $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => $i - $current_page_number, 'parameters' => $parameters))); } } $items[] = array('class' => array('pager-ellipsis'), 'data' => '…'); $items[] = array('class' => array('pager-item'), 'data' => theme('pager_last', array('text' => $total_number_of_pages, 'element' => $element, 'interval' => 1, 'parameters' => $parameters))); $items[] = array('class' => array('pager-next'), 'data' => $li_next); } /* Genarate pager with elpisis on left side. */ if ($current_page_number >= $pager_width && $current_page_number > $total_number_of_pages - $pager_width + 1) { if ($li_previous) { $items[] = array('class' => array('pager-previous'), 'data' => $li_previous); } $items[] = array('class' => array('pager-item'), 'data' => theme('pager_first', array('text' => "1", 'element' => $element, 'interval' => 1, 'parameters' => $parameters))); $items[] = array('class' => array('pager-ellipsis'), 'data' => '…'); for ($i = $total_number_of_pages - $pager_width + 1; $i <= $total_number_of_pages; $i++) { if ($i < $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => $current_page_number - $i, 'parameters' => $parameters))); } if ($i == $current_page_number) { $items[] = array('class' => array('pager-current'), 'data' => $i); } if ($i > $current_page_number) { $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => $i - $current_page_number, 'parameters' => $parameters))); } } $items[] = array('class' => array('pager-next'), 'data' => $li_next); } } /* Print generated pager */ return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => array('pager')))); }
<link rel="stylesheet" type="text/css" href="http://web-backend.local/css/facade.css"> </head> <body class="web-backend-inleiding"> <section class="body"> <p><?php echo berekenSom(4, 5); ?> </p> <p><?php echo vermenigvuldig(4, 5); ?> </p> <p><?php echo isEven(7); ?> </p> <p><?php foreach (returnStringArray('Dit is een hele gewone string.') as $value) { ?> <?php echo $value; ?> <?php } ?> </p> </section>
} function vermenigvuldig($getal1, $getal2) { return $getal1 * $getal2; } function isEven($getal) { if ($getal % 2 === 0) { return true; } else { return false; } } $optelling = berekenSom(5, 5); $maal = vermenigvuldig(5, 5); $isheteven = isEven(5); function geefLengteEnUppercase($string) { return array(strtoupper($string), strlen($string)); } $boodschap = geefLengteEnUppercase("schildpad"); ?> <!DOCTYPE html> <html> <head> <title>functions</title> </head> <body> <p><?php echo $optelling; ?>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>opdracht functions</title> </head> <body> <h1>Opdracht functions - deel 1</h1> <p> Som: <?php echo berekenSom(1, 2); ?> </p> <p> Vermenigvuldiging: <?php echo vermenigvuldig(1, 2); ?> </p> <p> Even: <?php echo isEven(25); ?> </p> <p> Uitbreiding: <?php var_dump(uitbreiding("Mijn naam is Ben")); ?> </p> </body> </html>
function vermenigvuldig($getal1, $getal2) { $uitkomst = $getal1 * $getal2; return $uitkomst; } function isEven($getal1) { if ($getal1 % 2 > 0) { return false; } return true; } $som = berekenSom(9, 11); $product = vermenigvuldig(9, 11); $evenGetal = 9; $evenheid = isEven($evenGetal); ?> <!DOCTYPE html> <html> <head> <title>Oplossing functies: deel1</title> </head> <body> <h1>Oplossing functies: deel1</h1> <p>9 + 11 = <?php echo $som; ?> </p>
public function testIsEvenPassString() { $this->assertFalse(isEven("fail")); }
<?php function isEven($getal) { if ($getal % 2 > 0) { echo "Het getal " . $getal . " is oneven. <br>"; } else { echo "Het getal " . $getal . " is even.<br>"; } } for ($i = 0; $i <= 100; $i++) { isEven($i); }
$resultaat = $getal1 * $getal2; return $resultaat; } function isEven($getal) { if ($getal % 2 == 0) { return "true"; } else { return "false"; } } ?> <!DOCTYPE html> <html> <p> <?php echo berekenSom(5, 3); ?> </p> <p> <?php echo vermenigvuldig(5, 3); ?> </p> <p> <?php echo isEven(8); ?> </p> </html>
function combi4($x, $y, $z) { $a = isEven($x); $b = isOdd($y); return someLogic($a, $b, $z); }
function isOdd($value) { return isEven($value - 1); }
/** This method displays the path instructions on the left side of the screen. @param $path<array[Segment]> the path found by the algorithm */ function printPath($path, $path_time) { global $website; $debug = false; $count = count($path); if ($debug) { echo "[display_functions.php:printPath()]<br/>\n"; echo "path count = {$count}<br/>\n"; if ($count > 1) { print_r($path); } else { echo "path = {$path}<br/>"; } } $old_lines = null; if ($count > 0) { // print consolidated path $directions_table = new Table(null, "info_table"); $header_row = new Row(null, "header_row"); $directions_table->addRow($header_row); $header_row->addCell(new Cell("header_cell", "Step")); $header_row->addCell(new Cell("header_cell", "Instructions")); $header_row->addCell(new Cell("header_cell", "Time")); for ($x = 0; $x < $count; $x++) { // create the row object if (isEven($x)) { $row_class = "rowHighlight"; } else { $row_class = "row"; } $row = new Row(null, $row_class); $y = $x + 1; // grab the segment and all its variables $segment = $path[$x]; if ($debug) { echo $segment . "<br/>"; echo "segment = " . $segment->toString() . "<br/>"; } $marker = $segment->m1; $m1_name = $marker->name; $m1lat = $marker->getLat(); $m1lng = $marker->getLng(); $m2_name = $segment->m2->name; $connection = $segment->connection; $step_cell = new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());", "[ {$y} ]")); $instruction_cell = new Cell("instruction"); $rawTime = $segment->t; $time_cell = new Cell("step_cell", getTimeString($rawTime)); if ($connection == "walking") { $instruction_cell->addData("Walk from <b>{$m1_name}</b> to <b>{$m2_name}</b>."); } else { if ($connection == "transfer") { $lines = $segment->lines; $from_string = ""; $to_string = ""; for ($i = 0; $i < count($old_lines); $i++) { $from_string .= "<img width=\"20\" src=\"images/" . $old_lines[$i]->img . "\"/>"; } for ($i = 0; $i < count($lines); $i++) { $to_string .= "<img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/>"; } $instruction_cell->addData("Transfer from <b>{$m1_name}</b> {$from_string} to <b>{$m2_name}</b> {$to_string}"); } else { // this is a regular segment $output_string = "Take "; $lines = $segment->lines; for ($i = 0; $i < count($lines); $i++) { $output_string .= "<a href=\"javascript:void(0);\" onclick=\"window.open('{$website}" . $lines[$i]->url . "');\"><img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/></a>"; } $output_string .= " from <b>{$m1_name}</b> to <b>{$m2_name}</b>."; $instruction_cell->addData($output_string); $old_lines = $lines; } } $row->addCell($step_cell); $row->addCell($instruction_cell); $row->addCell($time_cell); $directions_table->addRow($row); } $row = new Row(null, "total_row"); $row->addCell(new Cell(null, "")); $row->addCell(new Cell("total", "Total Time:")); $row->addCell(new Cell("total_time", getTimeString($path_time))); $directions_table->addRow($row); echo $directions_table->toString(); } else { echo "Sorry. No path found.<br/>\n"; } }
<html> <head> <meta charset="utf-8"> <title>oplossing deel1 fucnties</title> </head> <body> <p> 1+1 = <?php $uitkomst = berekenSom(1, 1); echo "{$uitkomst}"; ?> </p> <p> 6*6 = <?php $uitkomst = vermenigvuldig(6, 6); echo "{$uitkomst}"; ?> </p> <p> het getal 5 is <?php if (isEven(5)) { echo "wel "; } else { echo "niet "; } ?> even. </p> </body> </html>
?> </p> <p><?php echo $getal1; ?> * <?php echo $getal2; ?> = <?php echo vermenigvuldig($getal1, $getal2); ?> </p> <p><?php echo $getal1; ?> is <?php echo isEven($getal1) ? "even" : "oneven"; ?> </p> <p>"<?php echo $stringToCheck; ?> " is <?php echo stringCheck($stringToCheck)["lengte"]; ?> lang en "<?php echo stringCheck($stringToCheck)["uppercase"]; ?> " in uppercase.</p> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p><?php echo $getal1 . " + " . $getal2 . " = " . berekenSom($getal1, $getal2); ?> </p> <p><?php echo $getal1 . " * " . $getal2 . " = " . vermenigvuldig($getal1, $getal2); ?> </p> <p><?php echo $getal . " is "; if (isEven($getal)) { echo " even"; } else { echo " oneven"; } ?> </p> <p><?php echo var_dump(toUpper($tekst)); ?> </p> </body> </html>
return $arrResult; } ?> <!DOCTYPE html> <head> <meta charset="utf-8"> </head> <body> <p><?php echo berekenSom(1, 3); ?> </p> <p><?php echo vermenigvuldig(2, 3); ?> </p> <p><?php echo isEven(54875); ?> </p> <pre><?php print_r(lengthAndUpper("hello world")); ?> </pre> </body> </html>
} echo "functie 1 :" . som_berekenen(2, 2) . "<br>"; function vermenigvldiging($par1, $par2) { return $par1 * $par2; } echo "functie 2 :" . vermenigvldiging(2, 2) . "<br>"; function isEven($par1) { if ($par1 % 2 == 0) { return false; } else { return true; } } echo "functie 3 :" . isEven(3) . "<br>"; function lengte_en_upercase($string) { $array = array(); $array[] = strlen($string); $array[] = strtoupper($string); return $array; } $sting = lengte_en_upercase("opdracht is af"); echo "<p>lengte van de string is : " . $sting[0] . " en de string in Hoofdletters :" . $sting[1] . " </p>"; echo "deel 2 <br>"; function drukArrayAf($par) { foreach ($par as $key => $value) { $new_string_array[] = '[' . $key . '] met waarde ' . $value; }
<body> <h1>functions</h1> <?php echo "Cijfers zijn 2 & 7"; ?> <br><br> <?php echo "Som = " . berekenSom(2, 7); ?> <br> <?php echo "Product = " . vermenigvuldig(2, 7); ?> <br> Is 5 even? --> <?php echo isEven(5) ? "true" : "false"; ?> <p> Uitbreiding: <?php var_dump(uitbreiding("Mijn naam is Adriaan")); ?> </p> </body> </html>
color: red; } </style> </head> <body> <h1>Lesson 2</h1> <section id="exercise1"> <h3>Exercise 1</h3> <p>Create a function, called isEven, which returns the value TRUE if the number supplied is even, or FALSE if it is odd.</p> <?php for ($i = 0; $i < 10; $i++) { $x = rand(1, 999); if (isEven($x)) { echo $x . " = Odd" . PHP_EOL . "<br>"; } else { echo $x . " = Even" . PHP_EOL . "<br>"; } } ?> <?php ?> </section> <section id="exercise2"> <h3>Exercise 2</h3> <p>Create a function, which will print every parameter supplied on a
<li>Maak een functie <code>berekenSom</code> die 2 parameters heeft, <code>$getal1</code> en <code>$getal2</code></li> <li> Som = <?php echo berekenSom(2, 5); ?> </li> <li>Maak een functie <code>vermenigvuldig</code> die 2 parameters heeft, <code>$getal1</code> en <code>$getal2</code></li> <li>Vermenigvuldiging = <?php echo vermenigvuldig(2, 5); ?> </li> <li>Maak een functie <code>isEven</code> met 1 parameter <code>$getal</code> <li>Number 5 is even? <?php echo printf(isEven(5)); ?> </li> </li> <li class="extension">Maak een functie aan die de lengte én de uppercase-versie van een string returnt. Druk daarna de lengte en de uppercase-versie van de string af buiten de functie. <span class="tip">return een array.</span></li> <li><?php echo stringUpperCase("Functies"); ?> </li> </ul> <h1 class="extra">Opdracht functies: deel 2</h1> <ul> <li><?php
<?php //判断奇偶数 function isEven($a) { if (!is_numeric($a)) { return null; } $b = abs($a % 2); return $b ? false : true; } $a = mt_rand(1, 100); isEven($a); // 判断一个数字是否能被指定数整除 function isExactDiv($dividend, $divisor) { if (!is_numeric($dividend) || !is_numeric($divisor)) { return null; } return abs($dividend % 3) ? false : true; } $cc = isExactDiv($argv[1], $argv[2]); var_dump($cc);
/** Displays the station choices for choosing alternate stations when using direction finding. @param $url<String> the URL for the form @param $start_location<Location> the starting point for the search @param $end_location<Location> the ending point for the search @param $path_array[]<Segment> the path found in the original search */ function displayStationChoices($url, $start_location, $end_location, $path_array) { global $website, $station_marker_img; $debug = false; if ($debug) { echo $start_location->desc . " to " . $end_location->desc . "<br/>"; } // list alternate start stations $start_table = new Table(null, "choicetable"); $div = new Div("alternate_choices", "<b>Start Station Choices</b><br/>\n"); $div->addDataElement($start_table); $div->addDataElement("<br/>\n"); $header_row = new Row(null, "header_row"); $header_row->addCell(new Cell("header_cell", "Show")); $header_row->addCell(new Cell("header_cell", "Station Name")); $header_row->addCell(new Cell("header_cell", "Subway Lines")); $header_row->addCell(new Cell("header_cell")); $start_table->addRow($header_row); $start_stations = findNearestStations2($start_location); $start_station_marker = $path_array[0]->m2; if ($debug) { echo "start_station_marker->id = " . $start_station_marker->id . "<br/>"; } $i = 0; foreach ($start_stations as $station) { $station_marker = $station->marker; $station_lng = $station_marker->getLng(); $station_lat = $station_marker->getLat(); if (isEven($i)) { $class_name = "rowHighlight"; } else { $class_name = "row"; } $station_row = new Row($station_marker->id, $class_name); // station marker link $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0")))); $station_row->addCell(new Cell("instruction", $station_marker->name)); // build lines cell $lines = $station_marker->getLines(); $lines_cell = new Cell("instruction"); foreach ($lines as $line) { $line_img = $line->img; $line_url = $website . $line->url; $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');")); } $station_row->addCell($lines_cell); if ($start_station_marker->id == $station_marker->id) { $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" checked=\"true\"/>"; } else { $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" />"; } $station_row->addCell(new Cell("step_cell", $cell_data)); $start_table->addRow($station_row); $i++; } // list alternate end stations $div->addDataElement("<b>End Station Choices</b><br/>\n"); $end_table = new Table(null, "choicetable"); $div->addDataElement($end_table); $end_table->addRow($header_row); $end_stations = findNearestStations2($end_location); $end_station_marker = $path_array[count($path_array) - 1]->m1; if ($debug) { echo "end_station_marker->id = " . $end_station_marker->id . "<br/>"; } $i = 0; foreach ($end_stations as $station) { $station_marker = $station->marker; $station_lng = $station_marker->getLng(); $station_lat = $station_marker->getLat(); if (isEven($i)) { $class_name = "rowHighlight"; } else { $class_name = "row"; } $station_row = new Row($station_marker->id, $class_name); // station marker link $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0")))); $station_row->addCell(new Cell("instruction", $station_marker->name)); // build lines cell $lines = $station_marker->getLines(); $lines_cell = new Cell("instruction"); foreach ($lines as $line) { $line_img = $line->img; $line_url = $website . $line->url; $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');")); } $station_row->addCell($lines_cell); if ($end_station_marker->id == $station_marker->id) { $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" checked=\"true\"/>"; } else { $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" />"; } $station_row->addCell(new Cell("step_cell", $cell_data)); $end_table->addRow($station_row); $i++; } echo "<form id=\"form_pick\" action=\"{$url}\" method=\"get\">\n"; echo $div->toString(); echo "<input type=\"hidden\" name=\"type\" value=\"dir_alt\" />\n"; echo "<input type=\"hidden\" name=\"sa\" value=\"" . $start_location->getAddressString() . "\" />\n"; echo "<input type=\"hidden\" name=\"da\" value=\"" . $end_location->getAddressString() . "\" />\n"; echo "<br/>\n"; #echo "<input type=\"image\" name=\"submit\" src=\"images/usebutton.png\">\n"; echo "<div id=\"usebutton\"><input class=\"btn\" type=\"submit\" id=\"submit\" value=\"Use\"></div>\n"; echo "</form>"; }
function berekenVermenigvuldiging($getal1, $getal2) { $vermenigvuldig = $getal1 * $getal2; return $vermenigvuldig; } function isEven($getal) { if ($getal % 2 == 0) { return true; } return false; } $som = berekenSom(4, 5); $product = berekenVermenigvuldiging(4, 5); $getalPariteit = 11; $pariteit = isEven($getalPariteit); ?> <!DOCTYPE html> <html> <head> <title>Oplossing functies: deel1</title> </head> <body> <h1>Oplossing functies: deel1</h1> <p>Som 4, 5 <?php echo $som; ?> </p>
function isOdd($value) { return !isEven($value); }
function isEven($getal1) { $getal1 % 2 == 0 ? $bool = true : ($bool = false); return $bool; } //*********************************** DEEL 2 ******************************* ?> <!DOCTYPE html> <html> <head></head> <body> <h1>DEEL 1</h1> <p><?php echo berekenSom(4, 7); ?> </p> <p><?php echo berekenProduct(4, 7); ?> </p> <p><?php echo isEven(4); ?> </p> </body> </html>
$optellen = berekenSom(20, 15); function vermenigvuldig($getal1, $getal2) { $som = $getal1 * $getal2; return $som; } $vermenigvuldigen = vermenigvuldig(20, 15); function isEven($getal1) { if ($getal1 % 2 > 0) { return false; } else { return true; } } $even = isEven(8); function Stringtion($string) { $result['upper'] = strtoupper($string); $result['length'] = strlen($string); return $result; } $string = Stringtion('ik leer php'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>functions</title> </head>
$resultaat = ""; if ($getal % 2 == 0) { return $resultaat = true; } else { return $resultaat = false; } } function uitbreiding($string) { $lengte = strlen($string); $upper = strtoupper($string); return $resultaat = array($lengte, $upper); } $vermenig = vermenigvuldig(10, 6); $getaleven = 11; $iseven = isEven($getaleven); $string = 'Dit is een string'; $upEnLeng = uitbreiding($string); ?> <!DOCTYPE html> <html> <head> <title>Opdracht functies: deel 1</title> </head> <body> <h1>Opdracht functies: deel 1</h1> <p>De som van 10 en 6 = <?php echo berekenSom(10, 6); ?> </p>
{ $product = $getal1 * $getal2; return $product; } $berekenProductResult = berekenProduct($testGetal1, $testGetal2); function isEven($getal) { if ($getal % 2 === 0) { $result = TRUE; } else { $result = FALSE; $result = (int) $result; } return $result; } $isEvenResult = isEven($testGetal1); function stringToUpperLength($string) { $stringToUpper = strtoupper($string); $stringLength = strlen($string); $result = array($stringToUpper, $stringLength); return $result; } $stringToUpperLengthResult = stringToUpperLength($testString); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Opdracht functies</title>
} $som = berekenSom(5, 5); function vermenigvuldig($getal1, $getal2) { return $getal1 * $getal2; } $keer = vermenigvuldig(5, 5); function isEven($getal1) { if ($getal1 % 2 == 0) { return true; } else { return false; } } $iseven = isEven(4); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Opdracht-concat</title> </head> <body> <p> <?php echo "optellen" . $som . " vermenigvuldigen" . $keer . " is even ?" . $iseven; ?> </p>
De som van 4 en 5 is <?php echo berekenSom(4, 5); ?> </p> <p> Het product van 6 en 7 is <?php echo vermenigvuldig(6, 7); ?> </p> <p> Is het getal 8 even? <?php $getal = 8; if (isEven($getal) == true) { echo 'yup'; } else { echo 'nope'; } ?> </p> <p> Geef de lengte en uppercase versie van een string: <?php var_dump(upperLength("Dit is een string!")); ?> </p>