$url = 'https://google.com?q=test';
$parts = parse_url($url);
$result = http_build_url($parts);
Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
function pluralize( $count, $text )
{
return $count . ( ( $count == 1 ) ? ( " $text" ) : ( " ${text}s" ) );
}
function ago( $datetime )
{
$interval = date_create('now')->diff( $datetime );
$suffix = ( $interval->invert ? ' ago' : '' );
if ( $v = $interval->y >= 1 ) return pluralize( $interval->y, 'year' ) . $suffix;
if ( $v = $interval->m >= 1 ) return pluralize( $interval->m, 'month' ) . $suffix;
if ( $v = $interval->d >= 1 ) return pluralize( $interval->d, 'day' ) . $suffix;
if ( $v = $interval->h >= 1 ) return pluralize( $interval->h, 'hour' ) . $suffix;
if ( $v = $interval->i >= 1 ) return pluralize( $interval->i, 'minute' ) . $suffix;
return pluralize( $interval->s, 'second' ) . $suffix;
}
$options = array(
'safe_mode'=>true,
'open_basedir'=>'/var/www/users/jdoe/',
'allow_url_fopen'=>'false',
'disable_functions'=>'exec,shell_exec,passthru,system',
'disable_classes'=>'myAppClass');
$sandbox = new Runkit_Sandbox($options);
$sandbox->ini_set('html_errors',true);
// ...
$sandbox->eval('var_dump(isset($foo));');
$pid = getmypid();
// Add process ID to storage
// ...
//
// Retrieve process ID from storage
// ...
shell_exec(strtr('kill :pid', [
':pid' => $pid,
]));
$values = array_map(function($v){
return str_pad($v, 4, '0', STR_PAD_LEFT);
}, range(1, 9999));
action=pay-to-group&amount=1&group_id=183981859
hash (string) — строка, содержащая параметры платежа VK Pay и идентификатор приложения в параметре aid , разделенные &. Пример: action=transfer-to-group&group_id=1&aid=10.
Для использования этих функций необходимо скомпилировать PHP с поддержкой zip, используя конфигурационную опцию --enable-zip .
phpinfo();
$result = empty(array_filter($array, function($v){
return is_array($v) && isset($v['okey']) && $v['okey'] !== 1;
})) ? true : false;
$ext = pathinfo($path, PATHINFO_EXTENSION);
// Input
$data = extract($_POST);
// Output
$url = 'http://api.example.com';
$data = array('foo' => 'bar');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($ch);
curl_close($ch);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
fastcgi_finish_request();
$command = "(/usr/bin/php -q script.php) >/dev/null 2>&1 &";
exec($command);
$result = bcdiv(0.0100000000000000000001, 1, 2); // 0.01
$content = file_get_contents('http://www.example.com/');
* Please do not use this function, it is horribly ineffective.
* Instead use a reversed ORDER BY clause and a LIMIT 1 with R::findOne().
$order = R::findOne('orders', ' user_id = ? ORDER BY id DESC', [$user_id]);