What is the difference between Yii1.0 and Yii2.0?
1. Yii2.0 is completely managed using Composer;
2. Yii2.0 requires PHP5.4 or higher, while Yii1.0 requires the PHP version to be PHP5. 2;
3. Namespace is used in Yii2.0, and the "C" prefix of Yii1.0 is removed.
Yii2.0 PHP requirements
Yii 2.0 requires PHP 5.4 or higher, which is required compared to Yii 1.1 There are huge improvements in PHP 5.2. So there are a number of notable differences at the verbal level. The following is a summary of important changes in the PHP layer:
Namespace
Anonymous function
Array short syntax [...element...] is used to replace array(. ..element...)
The short echo tag = in the view file will always be recognized and valid since PHP 5.4, regardless of the setting of short_open_tag, and can be used safely.
SPL classes and interfaces
Delay static binding
Date and time
Traits
intl Yii 2.0 uses PHP to extend intl to Support related functions of internationalization.
Namespace
The most significant change in Yii 2.0 is the use of namespaces. Almost every core class introduces a namespace, such as yii\web\Request. The "C" class name prefix in version 1.1 is no longer used. The current naming scheme matches the directory structure. For example, yii\web\Request indicates that the corresponding class file is the web/Request.php file in the Yii framework folder.
(With Yii's class autoloader, you can directly use all core classes without explicitly including detailed files.)
Component (Component) and Object (BaseObject)
Yii 2.0 splits the CComponent class in 1.1 into two classes: yii\base\Object and yii\base\Component. The yii\base\Object class is a lightweight base class. You can define the properties of the object through getters and setters.
The Component class inherits from yii\base\Object and further supports events and actions.
If you do not need to use events or actions, you should consider using the yii\base\Object class as the base class. This type is generally used to represent basic data structures.
Recommended tutorial: "Yii"
The above is the detailed content of What is the difference between Yii1.0 and Yii2.0?. For more information, please follow other related articles on the PHP Chinese website!