Yii2 Tips 4 : URL Creation Bagian 3
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->method); echo "</pre>"; die(); ?> |
akan menghasilkan get atau post.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->user->isGuest ? 'true' : 'false'); echo "</pre>"; die(); ?> |
akan menghasilkan true atau false.
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isConsoleRequest ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isAjax ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isDelete ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isFlash ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isGet ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isHead ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isOptions ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isPatch ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isPjax ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isPost ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isPut ? 'true' : 'false'); echo "</pre>"; die(); ?> |
1 2 3 4 5 6 7 8 |
<?php use yii\helpers\Url; echo "<pre>"; print_r(Yii::$app->request->isSecureConnection ? 'true' : 'false'); echo "</pre>"; die(); ?> |
akan menghasilkan nilai true atau false.