示例#1
0
function convertSpeed($speed, $uomspeed, $addUom = false)
{
    $uom = '';
    if ($uomspeed == '5') {
        $speed *= 1.94384449;
        $uom = " knots";
    } else {
        if ($uomspeed == '4') {
            $speed = convertSeconds($speed * 0.037282272);
            $uom = " min/mi";
        } else {
            if ($uomspeed == '3') {
                $speed = convertSeconds($speed * 0.06);
                $uom = " min/km";
            } else {
                if ($uomspeed == '2') {
                    $speed *= 2.2369362920544025;
                    $uom = " mi/h";
                } else {
                    if ($uomspeed == '1') {
                        $speed *= 3.6;
                        $uom = " km/h";
                    } else {
                        $uom = " m/s";
                    }
                }
            }
        }
    }
    if ($addUom == true) {
        return number_format($speed, 2, '.', '') . $uom;
    } else {
        return number_format($speed, 2, '.', '');
    }
}
示例#2
0
}
//echo "www.php.net/manual/en/" ;
//similar to a regualr for loop in ruby , access to the key and value of
//a (hash in ruby language) an associative array (in php language)
foreach ($descriptions as $key => $value) {
    //echo "<li>$key is $value</li> ";
}
//below is declaring a variable then ucfirst is like Uppercase first char
// when passed the argument string to lower aka strtolower
//when passed in the variable name containg the value "JAKE"
$name = "JAKE";
$name = ucfirst(strtolower($name));
//echo $name;
?>
  
  <p>
  <?php 
//below is require from external file, which contains function
// which we then call later
//in this case both require and include work similarly in equivalent ways
require './convertseconds.php';
echo convertSeconds(2347);
//include simply includes a snippet from another external file
include './paragraph.html';
//below use var_dump to find out what is contained in a variable
var_dump($descriptions);
?>
  </p>
 </body>
</html>
示例#3
0
文件: require.php 项目: kamy333/kamy
<?php

require_once './includes/my_function.php';
require_once './includes/my_function.php';
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Using Require</title>
</head>

<body>
<h1>Including a Function</h1>
<p>3407 seconds converted to minutes and seconds: <?php 
echo convertSeconds(3407);
?>
</p>
</body>
</html>
示例#4
0
 public function convertSecondsToStr($seconds)
 {
     $output = convertSeconds($seconds);
     return $output['days'] . 'd ' . $output['hours'] . 'h ' . $output['minutes'] . 'm ' . $output['seconds'] . 's';
 }