w
0-php来结合服务端数据,处理前端页面的交互;
1-php 加法 乘法的效率对比,对算术运算的优化。
减少乘法运算?
function w_select($wname, $wii) { $w = '<select class="form-control" name="' . $wname . '">'; $wtmphour = intval(substr($wii, 0, strlen($wii) - 2)); $wtmp30 = intval(substr($wii, strlen($wii) - 2, 2)); $wtmphourb = $wtmphour; if ($wtmphour > 12) $wtmphourb = $wtmphour - 12; if ($wtmp30 == 0) { $wv = $wtmphour * 3600; $w .= ' <option value="' . $wv . '" >' . $wtmphourb . ':00</option>'; } $wv = $wtmphour * 3600 + 1800; $w .= ' <option value="' . $wv . '" >' . $wtmphourb . ':30</option>'; $wtmphour += 1; if ($wtmphour <= 12) { for ($wl = $wtmphour; $wl <= 12; $wl++) { $wv = $wl * 3600; $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>'; $wv = $wl * 3600 + 1800; $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>'; } for ($wl = 1; $wl <= 8; $wl++) { $wv = $wl * 3600 + 12 * 3600; $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>'; $wv = $wl * 3600 + 1800 + 12 * 3600; $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>'; } } else { for ($wl = $wtmphour - 12; $wl <= 8; $wl++) { $wv = $wl * 3600 + 12 * 3600; $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>'; $wv = $wl * 3600 + 1800 + 12 * 3600; $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>'; } } $w .= ' <option value="9:00">9:00</option>'; $w .= ' </select>'; return $w; }