Phalcon Kernel(2012～) ! hNps://github.com/phalcon/cphalcon/blob/master/ext/kernel/ README.md Phalcon Kernel is a meta- ‐framework on top of the Zend API helping to create PHP extensions in an easier way for a PHP developer.
In order to build a fast and stable framework, we have created the Phalcon Kernel. The use of this API helps us to write C code in a PHP style. We have developed a number of funcmons to help the programmer to write code more interoperable with PHP in a easier way.
Phalcon Kernel API is based on the Zend API, but we have added more features to facilitate us the work. Phalcon is a very large project, frameworks need to be developed and improved every day, Phalcon Kernel API helps us to write C code that is more stable and familiar to PHP developers.
Phalcon Kernel(2012～) ! 基於 ZEND API ! 提供大量 Helper funcmons / macros ! php style 的 c 開發風格
Data Types Create macro Long Boolean Double String value ZVAL_LONG() ZVAL_BOOL() ZVAL_DOUBLE() ZVAL_STRING() NULL ZVAL_NULL()
Data Types GeNer and Idenmfy macro Long Boolean Double String value String Length Z_LVAL() Z_BVAL() Z_DVAL() Z_STRVAL() Z_STRLEN() Z_LVAL_P() Z_BVAL_P() Z_DVAL_P() Z_STRVAL_P() Z_STRLEN_P() HashTable Object Z_ARRVAL() Z_OBJVAL() Z_ARRVAL_P() Z_OBJVAL_P() IdenLfy BOOL Long Double String NULL Z_TYPE() IS_BOOL IS_LONG IS_DOUBLE IS_STRING IS_NULL Z_TYPE_P()
Zephir ! Zephir - ‐ Ze(nd Engine) Ph(p) I(nte)r(mediate) ! A high level language that eases the creamon and maintainability of extensions for PHP. ! Zephir extensions are exported to C code that can be compiled and opmmized by major C compilers such as gcc/clang/vc++
Hello World! 開頭少了 <?php 語法幾乎相同。
Hel o World Generated C
Zephir - ‐ PHP Syntax Like
Basic ! Organizing Code in Files and Namespaces ! Every ﬁle must contain a class (and just one class). ! Every class must have a namespace ! The directory structure must match the names of classes and namespaces used. ( NOT Fol ow PSR- ‐0)
Variable DeclaraLons ! Declaramons
Variable Assignment ! Assignment / Value Change ! MUST Using let keyword.
Hashes NOT PHP k => v NOT JSON
For Statement ! A ‘for’ is a control structure that allows to traverse arrays or strings ! ! Keys in hashes can be obtained in the fol owing way:
Calling FuncLons ! To call a PHP funcmon, you can just refer its name in the Zephir