<?php echo "<br><br>"; $kokonimi = " markus norrena \n"; echo "Alussa: " . $kokonimi . " ."; //explode -- Split a string by string $nimet = explode(" ", $kokonimi); $kokonimi = ""; //ucfirst -- Make a string's first character uppercase foreach ($nimet as $nimi) { $kokonimi .= ucfirst($nimi) . " "; } //trim -- Strip whitespace (or other characters) from //the beginning and end of a string $kokonimi = trim($kokonimi); echo "Lopussa: " . $kokonimi . "."; function addname($first, $second) { $kokonainenimi = $first + $second; return $kokonainenimi; } echo addname($first, $second); echo "<br><br>"; echo addname($first, addnum(5, 6));
<?php /* function some_function( $argument1, $argument2) { //functioncode } */ function seb() { print "<h1>HALLO SEBASTIAN!</h1>"; } seb(); function printbr($txt) { print "{$txt}<br>\n"; } printbr("hei på deg"); printbr("dette er en ny linje"); function addnum($firstnum, $secondnum) { $result = $firstnum + $secondnum; return $result + seb(); } print addnum(50, 4); ?> </section> </main> </body> </html>