Skip to content

Instantly share code, notes, and snippets.

<?php
function convertToCelsiusDegrees($degrees, $scale = 'celsius')
{
if ($scale == 'fahrenheit') {
return $degrees * 1.8 + 32;
}
return $degrees;
}
<?php
function getWaterState($degrees, $scale = 'celsius')
{
$celsiusDegrees = $scale == 'fahrenheit'
? $degrees * 1.8 + 32
: $degrees;
if ($celsiusDegrees < 0) {
return 'This is solid ice';
}
<?php
function getWaterState($degrees, $scale = 'celsius')
{
if ($scale == 'fahrenheit') {
$celsiusDegrees = $degrees * 1.8 + 32;
} else {
$celsiusDegrees = $degrees;
}
if ($celsiusDegrees < 0) {
<?php
function getWaterState($degrees)
{
if ($degrees < 0) {
return 'This is solid ice';
}
if ($degrees > 100) {
return 'This is gaz water';
}
<?php
function getWaterState($degrees, $important = false)
{
if ($degrees < 0) {
$state = 'This is solid ice';
} elseif ($degrees > 100) {
$state = 'This is gaz water';
} else {
$state = 'This is liquid water';
}
<?php
function getWaterState($degrees)
{
if ($degrees < 0) {
return 'This is solid ice';
} elseif ($degrees > 100) {
return 'This is gaz water';
} else {
return 'This is liquid water';
}
@kylekatarnls
kylekatarnls / carbon-translators.md
Last active February 27, 2019 07:07
Carbon translators
<?php
$dateString = rtrim($_POST['date'], 'Z');
$date = new DateTimeImmutable("$dateString Asia/Tokyo");
echo $date->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s.u');
var date = new Date(dateString + 'T' + timeString + 'Z');
<?php
$date = new DateTimeImmutable($_POST['date']);
echo $date->format('Y-m-d H:i:s.u');