Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle kylekatarnls

  • France
View GitHub Profile
View split-function.php
<?php
function convertToCelsiusDegrees($degrees, $scale = 'celsius')
{
if ($scale == 'fahrenheit') {
return $degrees * 1.8 + 32;
}
return $degrees;
}
View ternary.php
<?php
function getWaterState($degrees, $scale = 'celsius')
{
$celsiusDegrees = $scale == 'fahrenheit'
? $degrees * 1.8 + 32
: $degrees;
if ($celsiusDegrees < 0) {
return 'This is solid ice';
}
View begin-else.php
<?php
function getWaterState($degrees, $scale = 'celsius')
{
if ($scale == 'fahrenheit') {
$celsiusDegrees = $degrees * 1.8 + 32;
} else {
$celsiusDegrees = $degrees;
}
if ($celsiusDegrees < 0) {
View split-function.php
<?php
function getWaterState($degrees)
{
if ($degrees < 0) {
return 'This is solid ice';
}
if ($degrees > 100) {
return 'This is gaz water';
}
View after-else.php
<?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';
}
View function-else.php
<?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';
}
View carbon-translators.md
View tokyo-to-utc.php
<?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');
View utc-date.js
var date = new Date(dateString + 'T' + timeString + 'Z');
View save-date.php
<?php
$date = new DateTimeImmutable($_POST['date']);
echo $date->format('Y-m-d H:i:s.u');
You can’t perform that action at this time.