1
我正在使用干預PHP的圖像操作。 是否可以通過像這樣的變量將字體大小和顏色應用於文本? 我算$字體大小和顏色$上面這一點,但它說未定義的變量如何在php中使用閉包函數中的變量?
$img->text($string, $item['x'], $top, function($font) {
$font->file('assets/fonts/Roboto-Medium.ttf');
$font->size($fontsize);
$font->color($color);
$font->align('left');
$font->valign('top');
});
謝謝你的回答! 我應該在這個右邊定義$字體? 你也可以請解釋我應該如何定義$字體? –
我已經編輯答案@AnithaIyer – Ali
瞭解:D $ img-> text($ string,$ item ['x'],$ top,function($ font)use($ fontsize,$ color){ $ font-> file('assets/fonts/Roboto-Medium.ttf'); $ font-> size($ fontsize); $ font-> color($ color); $ font-> align('left '); $ font-> valign('top'); }); 用這個意思^ 非常感謝! –