how to write php function

前端 未结 3 1285
無奈伤痛
無奈伤痛 2021-01-03 10:12

i want to know how i can write php function in c (like strtoupper). if is there any tutorial please put it here

thanks

相关标签:
3条回答
  • 2021-01-03 10:54

    To write a function in C, that can be used from PHP, you'll have to write an extension.

    There are not that many informations about that available, unfortunatly...

    Still, searching through my bookmarks, here are the links I found :

    • Extension Writing Part I: Introduction to PHP and Zend
    • Extension Writing Part II: Parameters, Arrays, and ZVALs
    • Extension Writing Part II: Parameters, Arrays, and ZVALs [continued]
    • Extension Writing Part III: Resources
    • Wrapping C++ Classes in a PHP Extension

    And, if you are really interested by the subject, and ready to spend some money on it, you could buy the book Extending and Embedding PHP (some pages are available as preview on Google Books too) ; I've seen a couple of times that it was the book to read when interested on this subject (In fact, I've bought it some time ago, and it's an interesting read)

    BTW, the author of that book is also the author of the first four articles I linked to ;-)

    0 讨论(0)
  • 2021-01-03 11:00

    If you just want to call a C function from PHP, you could use Gearman as an intermediary.

    http://gearman.org/

    http://pecl.php.net/package/gearman (PECL package)

    0 讨论(0)
  • 2021-01-03 11:01

    You might also be interested in SWIG, the Simplified Wrapper and Interface Generator:

    SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby.
    0 讨论(0)
提交回复
热议问题