#265 PHP +19
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

By Anonymous, 2018-03-13 21:56:00
const handleBoolean = value => {
        switch (value) {
            case "true":
                return true;
            case true:
                return "true";
            case "false":
                return false;
            case false:
                return "false"
            default:
                return null;
        }
    }
By Ifncn, 2022-01-27 07:49:16
  $guard = ($vars->a_payment) + (0) * $price;
  if ($bless >= $guard) {
    $amount = $bless;
  }

Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);

By Anonymous, 2018-02-05 17:27:25
if ($customerId > 0) {
    $customerId = $customerId;
} else {
    $customerId = $this->customerSession->getId();
}
By Anonymous, 2018-01-10 16:42:14
public static function getUser(){
    return \App\Models\User::all();
}
By mamadSiah, 2022-02-23 14:35:19
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;
}
By Anonymous, 2017-12-15 22:05:55
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);

found in a shopware plugin

By Anon, 2020-04-03 14:16:07
$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.

By Great PHP User, 2018-01-01 01:58:30
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#

By Unknown, 2017-12-12 14:42:38
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;
							}
					}
By PHPhillip, 2020-06-09 23:28:49
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;
}
By Anonymous, 2017-02-14 20:33:40
<?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.

By Anonymous, 2019-10-17 19:43:24
/**
 * 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);
}
By Anonymous, 2018-02-21 13:22:27
          //////////////////////////////////////////
          // Add ROI coordinates into Environment
          //////////////////////////////////////////
          AddROIcoordinatesIntoEnvironment();

It really helped me understand the code.

By Anonymous, 2022-05-30 00:49:45
    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);
    }
By Anonymous, 2018-01-10 09:01:18