PHP Yii Framework Global Variables Tutorial with Examples

PHP Yii Framework Global Variables Tutorial with Examples

Today, We want to share with you PHP Yii Framework Global Variables Tutorial with Examples.
In this post we will show you Yii CApplication, hear for php – declaring global variables in yii and use them in controller we will give you demo and example for implement.
In this post, we will learn about CApplication global variables – Yii Framework with an example.

Yii CApplication ->Yii::app()

CApplication is the base class for all application classes. It contains global variables, functions etc. Below We put some IMP PHP based yii most reused methods or functions and some basic config properties of yii web application. Basically we will call simple this functions Like as “Yii::app()”

Properties/ Functions Output
echo Yii::app()->baseUrl /yiiapi
Yii::app()->timeZone UTC
Yii::app()->setLanguage()
Yii::app()->setId()
Yii::app()->setHomeUrl()
Yii::app()->setBasePath()
Yii::app()->name My Web Application
Yii::app()->localeDataPath D:\wamp\www\yiiapi\yiiframework\framework\i18n\data
Yii::app()->language en_us
Yii::app()->id 3fe52c6c
Yii::app()->homeUrl /yiiapi/index.php
Yii::app()->getTimeZone() UTC
Yii::app()->getLanguage() en_us
Yii::app()->getId() 3fe52c6c
Yii::app()->getHomeUrl() /yiiapi/index.php
Yii::app()->getBaseUrl() yiiapi
Yii::app()->getBasePath() D:\wamp\www\yiiapi\protected
Yii::app()->createUrl(“/”) /yiiapi/index.php
Yii::app()->createAbsoluteUrl(“/”) http://127.0.0.1/yiiapi/index.php
Yii::app()->basePath D:\wamp\www\yiiapi\protected
Yii::app()->SetTimeZone() Asia/Calcutta

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Yii CApplication.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP access Global-Superglobals array Variables
  2.   sticky Scroll Back to Top Button using jQuery and CSS
  3.   Array Expressions using Angular Example
  4.   Laravel Dropzonejs Multiple File Upload using jQuery
  5.   Laravel set global Variable in middleware, all controller and views
  6.   How to Check Whether a Variable is Set or Not in laravel blade?
  7.   create more than one new company for Frontaccounting
  8.   PHP Functions - MY SQL Connects and Global Variable
  9.   Saving image from PHP URL - PHP Download Image from Url
  10.   PHP nested forloop - Exercises pyramid program Solution