$image = new Imagick();
$image->newImage(800, 75, new ImagickPixel('transparent'));
$draw = new ImagickDraw();
$draw->setFillColor('#000'); // цвет текста
$draw->setFont('path/to/font/Atial.ttf'); // путь до файла со шрифтом
$draw->setFontSize(30); // размер шрифта
$image->annotateImage($draw, 0, 0, 0, 'Текст Текст');
$image->setImageFormat('png');
PHP поддерживает списки аргументов переменной длины для функций, определяемых пользователем. Для версий PHP 5.6 и выше это делается добавлением многоточия (...). Для версий 5.5 и старше используются функции func_num_args(), func_get_arg() и func_get_args().
$array = array(
0 => array('id'=> 2, 'title' => 'text', 'category' => 0),
1 => array('id'=> 4, 'title' => 'text', 'category' => 1),
2 => array('id'=> 5, 'title' => 'text', 'category' => 0),
);
function catSort($a, $b)
{
if ($a['category'] == $b['category']) {
return 0;
}
return ($a['category'] < $b['category']) ? -1 : 1;
}
usort($array, "catSort");
print_r($array);
Array
(
[0] => Array
(
[id] => 2
[title] => text
[category] => 0
)
[1] => Array
(
[id] => 5
[title] => text
[category] => 0
)
[2] => Array
(
[id] => 4
[title] => text
[category] => 1
)
)
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
function* foo(){
var index = 0;
while(index <= 2)
yield index++; // yield будет прерывать работу функции на этом месте
}
var iterator = foo();
console.log(iterator.next()); // { index:0 }
console.log(iterator.next()); // { index:1 }
console.log(iterator.next()); // { index:2 }
Request URL:http://chehl.ru/page/2/
Request Method:GET
Status Code:404 Not Found
<?php $this->registerJs(
'jQuery(document).ready(function($){
var smallWindow = false;
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 50) {
$("#logo-image").attr("src", "'.Yii::getAlias("@web").'/images/logos/Monogram.png")
$(".important-class").addClass("padding-on-my-header");
}
if (scroll < 50) {
$(".important-class").removeClass("padding-on-my-header");
$("#logo-image").attr("src", "'.Yii::getAlias("@web").'/images/logos/PetCare_Monogram.png")
}
}).resize(function(){
if ( !smallWindow && this.innerWidth <= 1024 ) {
smallWindow = true;
$(".top-bar-section").find("ul.right").hide(0).delay(500).show(0);
}
if ( smallWindow && this.innerWidth > 1024 ) {
smallWindow = false;
}
});
});');
?>