php & so error: class not found [duplicate]
Possible Duplicate:
How can I use C++ code to interact with PHP?
I have the following test.php file:
<html>
<head>
<title>Personalized Hello World</title>
</head>
<body>
<?php include "/home/test.hpp";
$s= new example();
?>
</body>
</html>
the test.hpp file is:
#ifndef TEST_
#define TEST_
class example
{
public:
example();
void show();
};
#endif
I have the test.so file.
I compile .php with: php test.php -dextension=test.so
I have the error:
PHP Fatal error: Class 'example' not found in /var/www/test.php on line 10
How to resolve this? THX
You are trying to include C++ code from a PHP script. The PHP interpreter is not able to parse C++ code. Only PHP code. Because is a PHP interpreter. Not a C++ Compiler. These are different languages.
As @J0HN advises, you should read that : How can I use C++ code to interact with PHP?. It explains how to write extensions to PHP, which is the right way to interface PHP with C++ code.
精彩评论