Example #1
0
seperti ini.
function namafungsi(parameter1, parameter2, ... parameter n )
	{
		pernyataan berupa perintah operasi program;
	}
-->
<?php 
// pertama kita terlebih dahulu mendefinisikaan fungsinya,
// kemudian mengisi fungsi tersebut dengan sederetan perintah
function testing()
{
    echo "Contoh menggunakan Fungsi";
}
// untuk dapat menggunakan fungsi yang telah dibuat,
// perlu pemanggilan nama fungsinya.
testing();
?>


<!--******************************
Menggunakan parameter dalam fungsi
Parameter mewakili variable yang nilainya akan diolah. untuk menggunakan parameter
contohnya adalah seperti ini :-->
<?php 
function testing2($nilai)
{
    echo "Tinggi badan anda adalah" . $nilai;
}
$tinggibadan = 170;
testing2($tinggibadan);
?>
<?php

function testing($text)
{
    print_r(preg_split('/(\\s)*(\\\\)?\\,(\\s)*/i', $text));
    //	print_r(preg_split('/(?<!\\\\)(\,)/i', $text));
}
testing('Test A,Test');
testing('Test A , Test');
testing('Test A   , Test   B,   Test C');
testing('Test A \\, Test B');
Example #3
0
<?php

function testing($source)
{
    unset($source[$cos]);
}
testing($_GET);
echo "ok\n";
    <th >Jenis Pembayaran </th>
   
    <th>Biaya Kuliah Reguler </th>
    <th>Biaya Wisuda </th>
    <th>Lain Lain </th>
  
  </tr>
      <?php 
$no = 1;
$jumlah = 0;
$totalsmpp = 0;
$totalwisuda = 0;
$totallain = 0;
foreach ($transaksi as $r) {
    $spp = testing($r->jenis_bayar_id, 3, $r->jumlah);
    $wisuda = testing($r->jenis_bayar_id, 7, $r->jumlah);
    $lain = testing2($r->jenis_bayar_id, $r->jumlah);
    echo "<tr>\n    <td>{$no}</td>\n    <td width='90'>" . tgl_indo($r->tanggal) . "</td>\n    <td width='40'>" . strtoupper($r->nim) . "</td>\n    <td>" . strtoupper($r->nama) . "</td>\n    <td>" . strtoupper($r->jenis_bayar) . "</td>\n    <td>" . $spp . "</td>\n\n \n    <td>" . $wisuda . "</td>\n    <td>" . $lain . "</td>\n   <td>{$r->jumlah}</td>\n  </tr>";
    $no++;
    $totallain = $totallain + $lain;
    $totalsmpp = $totalsmpp + $spp;
    $totalwisuda = $totalwisuda + $wisuda;
}
?>
    <tr>
    <td colspan=5><p align="right" >Total</p></td>
    <td><?php 
echo rp((int) $totalsmpp);
?>
</td>
     <td><?php 
Example #5
0
            $handler = $routeInfo[1];
            $vars = $routeInfo[2];
            // ... call $handler with $vars
            $handler($uri, $vars);
            break;
    }
}
function testing(Ubench $bench, $requestURI)
{
    $_SERVER['REQUEST_URI'] = $requestURI;
    echo "\n----------------\ntesting for url: [" . $_SERVER['REQUEST_URI'] . "]\n";
    echo "bench gymadarasz/router\n";
    $bench->start();
    gymadarasz_router();
    $bench->end();
    echo "time:\t" . $bench->getTime() . ' (' . $bench->getTime(true) . ')' . PHP_EOL;
    echo "mem:\t" . $bench->getMemoryUsage() . PHP_EOL;
    echo "\nbench nikic/fast-route\n";
    $bench->start();
    nikic_fast_route();
    $bench->end();
    echo "time:\t" . $bench->getTime() . ' (' . $bench->getTime(true) . ')' . PHP_EOL;
    echo "mem:\t" . $bench->getMemoryUsage() . PHP_EOL;
}
echo "<pre>";
$bench = new Ubench();
testing($bench, '');
testing($bench, '/test');
testing($bench, '/test/keyword');
testing($bench, '/test/123');