Server and User System Information
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->hostInfo); echo "</pre>"; die(); ?> |
adalah http://yii2tips.local
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->userAgent); echo "</pre>"; die(); ?> |
menghasilkan browser yang digunakan.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->userIP); echo "</pre>"; die(); ?> |
akan menghasilkan userIP.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->securePort); echo "</pre>"; die(); ?> |
akan menghasilkan secure port, 443.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->serverName); echo "</pre>"; die(); ?> |
akan menghasilkan serverName, yii2tips.local.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->serverPort); echo "</pre>"; die(); ?> |
akan menghasilkan server port, 80.
Mengetahui Controller, Module, dan Action
1 2 3 |
echo Yii::$app->controller->id; echo Yii::$app->controller->action->id; echo Yii::$app->controller->module->id; |