Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Bug fix for your scoring script

$
0
0

Replies: 0

In motorracingleaguescoring.php line #50, comparison “$key == 0” :

if ($options->get_predict_pole() && $key == 0 && isset($drivers[0]) && $guess == $drivers[0]['id']) {

Your use of ‘==’ causes PHP’s type coercion to cast string values of $key to be the integer 0, meaning that conditional can be satisfied with values like “rain” or “safety_car”, leading to extra pole position prediction points being erroneously added.

Top tip: Always use ‘===’ to guarantee type safe comparisons. 🙂

  • This topic was modified 15 minutes ago by abulia.

Viewing all articles
Browse latest Browse all 59525

Trending Articles