开发者

php & so error: class not found [duplicate]

This question already has answers here开发者_JAVA百科: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜