class Config {
private static $configData;
public static function get($parameter = null, $default = null)
{
if (is_null(self::$configData)) {
self::$configData = include '../config.php';
}
if ($parameter) {
return self::$configData[$parameter] ?? $default;
}
return self::$configData;
}
}
// в клиентском методе
public function someMethod() {
$config = Config::get();
}
<?php
// в config.php
return [
'param' => 'value',
];
?>
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://......../');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec ($ch);
curl_close ($ch);
/**
* Tests if an array is associative or not.
*
* @param array array to check
* @return boolean
*/
public static function is_assoc(array $array)
{
// Keys of the array
$keys = array_keys($array);
// If the array keys of the keys match the keys, then the array must
// not be associative (e.g. the keys array looked like {0:0, 1:1...}).
return array_keys($keys) !== $keys;
}