Php problem for school. Why doesn't this work

[php]<?php
$speed = 8;
$cost = $0;
if ($speed >= 11){
$cost == ($speed - 10) * 5;
echo "Your speed was " . $speed . ". Your ticket costs " .$cost;
} elseif ($speed >= 16){
$cost == 25 + (($speed - 15) * 10);
echo "Your speed was " . $speed . ". Your ticket costs " .$cost;
} elseif ($speed >= 21){
$cost == 75 + (($speed - 20) * 25);
echo "Your speed was " . $speed . ". Your ticket costs " .$cost;}
else: echo “You get a warning.”;?>[/php]

Can you give more of a question? What happens?

Look through your code. When is 8 greater than 11, or 21?

Also, $cost cannot equal $0; it CAN equal 0, but the dollar sign is for display, not the variable.

Sponsor our Newsletter | Privacy Policy | Terms of Service