Home>
namespace yii \ widgets;
use yii \ base \ widget;
use yii \ helpers \ html;
class hellowidget extends widget
{
public $message;
public function init ()
{
parent ::init ();
if ($this->message === null) {
$this->message="hello world";
}
}
public function run ()
{
return html ::encode ($this->message);
}
}

Calling method

<?php
use app \ components \ hellowidget;
?>
<?= hellowidget ::widget (["message" =>"good morning"])?>
php
  • Previous Summary of methods for generating image verification codes in PHP (2 methods)
  • Next Example analysis of cookie usage in Yii2