if((strtotime(date("Y-m-d"))-strtotime(date("Y-m-d", filemtime($filename))))/(3600)<=$config->hourDiff) return true; else return false;
please notice the brackets around 3600
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
$guard = ($vars->a_payment) + (0) * $price;
if ($bless >= $guard) {
$amount = $bless;
}
Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);
if ($customerId > 0) {
$customerId = $customerId;
} else {
$customerId = $this->customerSession->getId();
}
public static function getUser(){
return \App\Models\User::all();
}
function prepareKeyword($keyword) {
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = iconv("ISO-8859-1", "UTF-8", $keyword);
$keyword = cleanString($keyword);
$keyword = html_entity_decode($keyword);
if ($keyword != "") {
$keyword = mb_strtolower($keyword, "UTF-8");
$keyword = htmlentities($keyword, ENT_HTML5);
}
return $keyword;
}
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);
found in a shopware plugin
$url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fwww.google.com%2Ffinance%3Fq%3D' . $stock_identifier . '%26fstype%3Dii%26ei%3DCFrdWImFNdiGe_atlegC%22%20and%20compat%3D%22html5%22%20and%20xpath%3D' . "'%2F%2Ftable%5Bcontains(%40class%2C%22gf-table%20rgt%22)%5D'" . '&format=json&diagnostics=true&callback=';
$json = json_decode($this->getJsonFromYql($url), true);
$json = $json["query"]["results"]["table"];
//If the value is red, that means there is an additional span class which needs to be checked through.
$response["revanueValue"] = empty($json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"];
$response["costofRevanue"] = $json["1"]["tbody"]["tr"]["3"]["td"]["1"]["content"];
$response["operatingIncome"] = empty($json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"];
$response["netIncome"] = empty($json["1"]["tbody"]["tr"]["24"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["24"]["td"]["1"]["span"]["content"] : $json["0"]["tbody"]["tr"]["24"]["td"]["1"]["content"];
$response["dividendsPerShare"] = $json["1"]["tbody"]["tr"]["35"]["td"]["1"]["content"];
$response["dilutedNormalizedEps"] = empty($json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"];
$response["minorityInterest"] = $json["1"]["tbody"]["tr"]["18"]["td"]["1"]["content"];
Website --> Json --> PHP Parsing Beautiful.
public override List<Value> Values
{
get
{
if (_values == null && shouldLoadLazily)
{
_values = _lazerLoader.LoadValues<Value>()
}
return _values;
}
set
{
throw new InvalidOperationException("Values are actually readonly- please set in constructor")
}
}
How to create immutable fields in c#
if (isLink($content[$i][$j])) {
if (isImageLink($content[$i][$j])) {
$image_src = create_image($content[$i][$j], "img");
$cell = <<<HTML
<td>
<img {$image_src} {$img_style}></td></img>
</td>
HTML;
} else if (isNestedLink($content[$i][$j])) {
$links = explode("!", $content[$i][$j]);
$cell = <<<HTML
<td><a style="color: {$cards_button_bg_color};" href="{$links[1]}" $open_links_in >{$links[0]}</a></td>
HTML;
} else {
//Checking if it's a link or a button
if ($j == $table_button_column) {
//Button HTML
$table_button_text = explode("-", $content[0][$j])[0];
$cell = <<<HTML
<td><a {$open_links_in} href="{$content[$i][$j]}" style="background-color: {$cards_button_bg_color}; color: {$cards_button_text_color};" class="btn">{$table_button_text}</a></td>
HTML;
} else {
// Link HTML
$cell = <<<HTML
<td><a style="color: {$cards_button_bg_color};" href="{$content[$i][$j]}" $open_links_in >{$content[0][$j]}</a></td>
HTML;
}
}
if(!isset($obj->{'s5_4-1'})) {
$obj->{'s5_4-1'} = 0;
}
if(!isset($obj->{'s5_4-2'})) {
$obj->{'s5_4-2'} = 0;
}
if(!isset($obj->{'s5_4-3'})) {
$obj->{'s5_4-3'} = 0;
}
if(!isset($obj->{'s5_4-4'})) {
$obj->{'s5_4-4'} = 0;
}
<?php
class CasinoCode
{
CONST POST = 'POST';
CONST GET = 'GET';
$data = $this->callAPI('/hidden', [], self::POST);
production code of an API with dozens of millions of requests per day.
/**
* Creates hash of client/customer password
* @param string $password The actual password
* @return string MD5 hash of password with salt
*/
public static function hashPassword($password)
{
return md5($password . $password. 'SOME-SECRET-STRING' . $password);
}
//////////////////////////////////////////
// Add ROI coordinates into Environment
//////////////////////////////////////////
AddROIcoordinatesIntoEnvironment();
It really helped me understand the code.
foreach ($desired_components as $name => $junk) {
list($component_value, $component_comments) = self::unpackPair($desired_components[$name]);
$desired_components[$name] = self::packPair(round($component_value, 2), $component_comments);
}