Hi I am trying to create a php calculator which basically does this:
$price_m_Fuengirola = 11.00;
/* number of people */
$car1 = 0.00; /* 1-4 */
$car2 = 50.00; /* 4-8 */
$car3 = 70.00; /* 8-12 */
$car4 = 90.00; /* 12-16 */
/* Calculator */
date_default_timezone_set('GMT');
//echo $newTime;
echo $price_m_Fuengirola."<br />";
echo $car2."<br />";
function timeCalc(){
$newTime = date("H:i", time());
if ($newTime < "18:56"){
echo 20.00;
//echo "<br />this is more time";
} else {
echo 6.00;
//echo "this is more time";
}
}
$timeCalc = timeCalc();
echo $timeCalc."<br />";
$total = $price_m_Fuengirola + $car2 + $timeCalc."<br /><br />";
echo $total;`
The logic behind it is if a person orders a taxi before x time then they get charged x else they get charged x (i plan to change it when i manage to get it working), the issue is the price is being added to the car price but not to the function price output. In the function I am trying to only echo a number which isn’t meant to be time so am I missing something?
Here is my particular take:
http://ideone.com/owfLg
Note, I’m comparing two arguments,
$now(which is a timestamp), and$cutoff, which is anhh:mmrepresentation of the cutoff time to check. Theforloop is to demonstrate the outcomes per hour, which would be: