1 / 12

FUNKCE V PHP

FUNKCE V PHP. FUNKCE JSOU V PODSTATĚ MALÉ KUSY SKRIPTŮ, KTERÉ JE MOŽNÉ OPAKOVANĚ POUŽÍVAT. <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function pozdrav() { echo "Ahoj!<br>"; } pozdrav();

moses
Télécharger la présentation

FUNKCE V PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FUNKCE V PHP

  2. FUNKCE JSOU V PODSTATĚ MALÉ KUSY SKRIPTŮ, KTERÉ JE MOŽNÉ OPAKOVANĚ POUŽÍVAT. <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function pozdrav() { echo "Ahoj!<br>"; } pozdrav(); pozdrav(); ?> </body> </html>

  3. FUNKCE - PARAMETRY <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function sečti($a, $b) { echo $a, " + ", $b, " = ", $a+$b, "<br>"; } sečti(1,2); sečti(3,4); ?> </body> </html>

  4. PŘÍKAZ RETURN - PŘEDČASNÉ UKONČENÍ FUNKCE <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function vydel($a, $b) { if ($b == 0) return; echo $a, " / ", $b, ' = ', $a/$b, "<br>"; } vydel(10,5); vydel(2,0); vydel(100,4); ?> </body> </html>

  5. FUNKCE STRLEN - POČET ZNAKŮ ŘETĚZCE <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php $kolik = strlen("Ahoj"); echo $kolik, "<br>"; echo strlen("Nazdar"); ?> </body> </html>

  6. PŘÍKAZ RETURN - VRÁCENÍ HODNOTY FUNKCE <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function vynásob($a, $b) { return $a * $b; } $výsledek = vynásob(2,3); echo $výsledek, "<br>"; echo vynásob(4,5); ?> </body> </html>

  7. JEDNODUŠŠÍ PŘÍKLAD <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php function p() { return 3.141592653589; } echo "Pi = ", p(), "<br>"; ?> </body> </html>

  8. FUNKCE MT_RAND - NÁHODNÉ ČÍSLO <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php $náhodné_číslo = mt_rand(1,2); if ($náhodné_číslo == 1) echo "Ahoj frajere!"; else echo "Ahoj kamaráde!"; ?> </body> </html>

  9. PŘEVODNÍ FUNKCE <html> <head> <title>Příklad </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> </head> <body> <?php echo decbin(10); ?> </body> </html>

  10. OSTATNÍ FUNKCE

  11. OSTATNÍ FUNKCE VŠECHNY FUNKCE MAJÍ DVA POVINNÉ PARAMETRY A JEDEN NEPOVINNÝ, KTERÝ ÚDÁVÁ POČET MÍST K ZAOKROUHLOVÁNÍ

  12. OSTATNÍ FUNKCE

More Related