PHP Extension Development Tutorials, examples to demonstrate the PHP extension development and underlying application principles (C language non-Zephir)

Source: Internet
Author: User

Mainly uses the C language to develop the PHP extension, now the case is step by step consummation, hoped has the interest friend to join and Consummates, now has completed the case as follows:

dicretory Explain
Hello_word PHP Hello Word extension
Widuu PHP ini settings and read PHP ini configure
W_string PHP Returning values

Contributing

  • Login https://github.com
  • Warehouse Address Distribution Http://github.com/widuu/php_ext
  • Create your feature branch (git checkout-b my-new-feature)
  • Commit your changes (git commit-am ' Added some feature ')
  • Submit your change history to a remote Git repository (Git push origin my-new-feature)
  • Pull Request is then launched under the My-new-feature branch of the GIT remote repository on the github.com website
  • Below is the small extension code fragment of INI

    #ifdef have_config_h#include "config.h" #endif include "Php.h" #include "php_ini.h" #include "ext/standard/info.h" # Include "Php_widuu.h" Zend_declare_module_globals (widuu) const Zend_function_entry widuu_functions[] = {PHP_FE (read_ INI, NULL) php_fe_end};zend_module_entry widuu_module_entry = {#if zend_module_api_no >= 20010901 STA           Ndard_module_header, #endif "Widuu", Widuu_functions, Php_minit (Widuu), Php_mshutdown (Widuu), NULL, NULL, Php_minfo (Widuu), #if zend_module_api_no >= 20010901 php_widuu_version, #endif standard_module_pr Operties}; #ifdef Compile_dl_widuuzend_get_module (Widuu) #endifPHP_INI_BEGIN () std_php_ini_entry ("Widuu.enable", "1 ", Php_ini_all, Onupdatebool, Enable, Zend_widuu_globals, widuu_globals) std_php_ini_entry (" Widuu.size "," $ ", PHP _ini_all, Onupdatelong, size, zend_widuu_globals, widuu_globals) std_php_ini_entry ("Widuu.name", "Widuu", PHP_INI_ALL , onupdatestring, name, Zend_widuu_globalS, widuu_globals) Php_ini_end () php_minit_function (Widuu) {register_ini_entries (); return SUCCESS;}    /*}}} *//* {{{php_mshutdown_function */php_mshutdown_function (widuu) {unregister_ini_entries (); return SUCCESS;}    /*}}} *//* {{{php_minfo_function */php_minfo_function (widuu) {Php_info_print_table_start ();    Php_info_print_table_header (2, "Widuu support", "enabled");    Php_info_print_table_row (2, "author", "Widuu");    Php_info_print_table_end (); Display_ini_entries ();}    /*}}} */php_function (Read_ini) {char *str,*varname;    int str_len; if (Zend_parse_parameters (Zend_num_args () tsrmls_cc, "s", &varname,&str_len) = = FAILURE) {Php_error_docref        (NULL tsrmls_cc, e_warning, "don ' t exists parameter");    Return    } str = zend_ini_string (varname, str_len+1, 0);    if (!str) {return_false;    } return_string (str, 1);    str = zend_ini_string ("Widuu.name", sizeof ("Widuu.name"), 0); Long maxwait = Zend_ini_long ("widuu.siZe ", sizeof (" Widuu.size "), 0);    if (str = = NULL) {//Php_error_docref ("Widuu.size", e_warning, "config NOT exists");    }//printf ("%s\n", str);    printf ("%d\n", maxwait);    if (name = NULL) {//printf ("%s\n", name); }//Return_false;}

    function string Read_ini (string parameter);

    echo Read_ini (' widuu.name ');
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.