eigene c++ lib dll für php



  • Hallo,
    hat von euch schonmal jemand versucht ne lib dll oder sowas für php zu erstellen.
    Einfach ne simple funktion die über ausführbar ist z.B.

    #include <stdlib>
    #include "string.h"
    
    int main()
    {
      printf("hallo");
    }
    

    Geht sowas überhaupt?
    Danke



  • Na mit int main() wirst du da nicht weit kommen.

    Du musst deine Funktionen schon "exportieren" damit du sie benutzen kannst.
    Und wenn du PHP mit der dll benutzen willst, musst du dich um die Konvertierung der Datentypen kümmern. Da weiß ich nicht, wie man das in PHP handhabt.

    Kleines Gerüst für ne dll:

    // interface.h
    
    _declspec (dllexport) int square(int source);
    
    // interface.cpp
    #include "interface.h"
    
    _declspec (dllexport) int square(int source)
    {
        return source*source;
    }
    

Anmelden zum Antworten