Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //functions.php
- <?php
- function tabela_emails($emails) {
- echo '<table><tr><th>Email</th><th>Nome</th></tr>';
- asort($emails);
- foreach($emails as $email => $nome) {
- echo '<tr>' . '<td>' . $email . '</td>' . '<td>' . $nome . '</td>' . '</tr>';
- }
- echo '</table>';
- }
- function devolve_maior($num1, $num2, $num3) {
- if(is_numeric($num1) && is_numeric($num2) && is_numeric($num3) ) {
- if($num1 > $num2 && $num1 > $num3) {
- return $num1;
- }
- else if($num2 > $num1 && $num2 > $num3) {
- return $num2;
- }
- else {
- return $num3;
- }
- }
- else {
- return null;
- }
- }
- function inverte_string($str) {
- if(is_string($str)) {
- return strrev($str);
- }
- else {
- return null;
- }
- }
- //php06.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <title>PHP: Utilização de associativos</title>
- </head>
- <body>
- <?php
- $emails = array("joao@mail.pt"=>"João Silva", "jorge@mail.pt"=>"Jorge Pereira", "sonia@mail.pt"=>"Sónia Silva", "ana@mail.pt"=>"Ana Duarte");
- foreach($emails as $email => $nome) {
- echo $email . ' - ' . $nome . '<br>';
- }
- ?>
- </body>
- </html>
- //php07.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <title>PHP: Produção HTML + Funções</title>
- </head>
- <body>
- <?php
- $emails = array("joao@mail.pt"=>"João Silva", "jorge@mail.pt"=>"Jorge Pereira", "sonia@mail.pt"=>"Sónia Silva", "ana@mail.pt"=>"Ana Duarte");
- tabela_emails($emails);
- function tabela_emails($emails) {
- echo '<table><tr><th>Email</th><th>Nome</th></tr>';
- asort($emails);
- foreach($emails as $email => $nome) {
- echo '<tr>' . '<td>' . $email . '</td>' . '<td>' . $nome . '</td>' . '</tr>';
- }
- echo '</table>';
- }
- ?>
- </body>
- </html>
- //php08.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <title>PHP: Inclusão Ficheiros</title>
- </head>
- <body>
- <?php
- require_once('include/functions.php');
- $emails = array("joao@mail.pt"=>"João Silva", "jorge@mail.pt"=>"Jorge Pereira", "sonia@mail.pt"=>"Sónia Silva", "ana@mail.pt"=>"Ana Duarte");
- tabela_emails($emails);
- ?>
- </body>
- </html>
- //php09.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <title>PHP: Funções Numéricas</title>
- </head>
- <body>
- <?php
- require_once('include/functions.php');
- $numero = devolve_maior(10,3,6);
- echo $numero;
- ?>
- </body>
- </html>
- //php10.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <title>PHP: Funções de Strings</title>
- </head>
- <body>
- <?php
- require_once('include/functions.php');
- $string_invertida = inverte_string("MARIA");
- echo $string_invertida;
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement