import React, { Component } from 'react';
class MyComponent extends Component {
// standard function bind
constructor(props) {
super(props);
this.onClickBar = this.onClickBar.bind(this);
}
onClickBar(event) {
// valid "this" only if bound in constructor
}
// babel-plugin-transform-class-properties is required for this syntax
onClickFoo = (event) => {
// "this" is always valid
};
render() {
return (
<div>
<button onClick={this.onClickFoo}>foo</button>
<button onClick={this.onClickBar}>bar</button>
</div>
);
}
}
function round_to_nearest($number, $divider)
{
return round($number / $divider) * $divider;
}
var_dump(round_to_nearest(110, 10));
var_dump(round_to_nearest(130, 50));
var_dump(round_to_nearest(56, 50));
var_dump(round_to_nearest(11, 10));
var_dump(round_to_nearest(1.3, 0.5));
var_dump(round_to_nearest(0.14, 0.05));
float(100)
float(150)
float(50)
float(10)
float(1.5)
float(0.15)
<?php
$rawJson = '{"response":1,"counts People":1849}';
$jsonObj = json_decode($rawJson);
$jsonArray = json_decode($rawJson, true);
var_dump($jsonObj, $jsonArray);
var_dump($jsonObj->{'counts People'});
var_dump($jsonArray['counts People']);
object(stdClass)#1 (2) {
["response"]=>
int(1)
["counts People"]=>
int(1849)
}
array(2) {
["response"]=>
int(1)
["counts People"]=>
int(1849)
}
int(1849)
int(1849)
/**
* Get the cookie lifetime in seconds.
*
* @return \DateTimeInterface
*/
protected function getCookieExpirationDate()
{
$config = $this->manager->getSessionConfig();
return $config['expire_on_close'] ? 0 : Carbon::now()->addMinutes($config['lifetime']);
}