We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I make a simple demo , like this
#include <phpcpp.h> #include void myFunction() { Php::out << "hello world" << std::endl; } extern "C" { PHPCPP_EXPORT void *get_module() { static Php::Extension extension("my_extension", "1.0"); extension.add("myFunction"); return extension; } }
but ,when I test this extension , the CLI mode echo :
"hello world Segmentation fault"
The text was updated successfully, but these errors were encountered:
It seems you have few errors in your files.
your file:
#include <phpcpp.h> #include /* MISSING INCLUDE FILE */ void myFunction() { Php::out << "hello world" << std::endl; } extern "C" { PHPCPP_EXPORT void *get_module() { static Php::Extension extension("my_extension", "1.0"); extension.add("myFunction"); /* MISSING FUNCTION TYPE <myFunction> */ return extension; /* MISSING METHOD module() LESS IMPORTANT WORKS WITHOUT*/ } }
simpledemo.cpp after correction + change name of extension from my_extension to simpledemo
#include <phpcpp.h> #include <iostream> void myFunction() { Php::out << "hello world" << std::endl; } extern "C" { PHPCPP_EXPORT void *get_module() { static Php::Extension extension("simpledemo", "1.0"); extension.add<myFunction>("myFunction"); return extension.module(); } }
simpledemo.php
#!/usr/bin/env php <?php declare(strict_types=1); $extname = 'simpledemo'; if ( ! extension_loaded($extname) ) { if ( false === @dl($extname.'.so') ) die('Unable to load extension '.$extname.PHP_EOL); } echo myFunction() . "\n";
All works fine.
Examples files provided with PHPCPP are good templates for your usage but copy or modify them carefully.
Sorry, something went wrong.
No branches or pull requests
I make a simple demo , like this
#include <phpcpp.h>
#include
void myFunction()
{
Php::out << "hello world" << std::endl;
}
extern "C" {
PHPCPP_EXPORT void *get_module() {
static Php::Extension extension("my_extension", "1.0");
extension.add("myFunction");
return extension;
}
}
but ,when I test this extension , the CLI mode echo :
"hello world
Segmentation fault"
The text was updated successfully, but these errors were encountered: