Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

Extension and Embeding in PHP

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

Extension and Embeding in PHP

Postby Antrikssh » Sun May 06, 2012 10:57 pm

Hi,
I have installed php-5.3.10 in my fedora 15 system. I want to learn and work with php for my applications. I want wrapping c++ with php for that I have preffered link (http://devzone.zend.com/1435/wrapping-c ... extension/) that I founded by googling. I have read the document from the starting and try for understand it as per my knowlege level. I have uderstand entire procedure but the last step that mention in the document. I unable to understand that one the code as follow

// create a 5 gear car
$car = new Car(5);
print $car->getCurrentSpeed(); // prints '0'
$car->accelerate();
print $car->getCurrentSpeed(); // prints '5'

i want to ask that where should I will write this code in vehicles.cc file or .php file because i both the condition I got error. If some one is there who can tell me the proper working of that code.

Please help me to out of this....

Thanks and Regards,

Antrikssh.....
:)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: Extension and Embeding in PHP

Postby faust » Tue May 08, 2012 2:52 am

give the code of getCurrentSpeed() and accelerate() and we may be able to help.
faust
New php-forum User
New php-forum User
 
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Re: Extension and Embeding in PHP

Postby Antrikssh » Tue May 08, 2012 5:35 am

Hi,

Thanks for your time that you gave me, the required code given below....

PHP_METHOD(accelerate)
{
Car *car;
car_object *obj = (car_object *)zend_object_store_get_object(
getThis() TSRMLS_CC);
car = obj->car;
if (car != NULL) {
car->accelerate();
}
}
PHP_METHOD(getCurrentSpeed)
{
Car *car;
car_object *obj = (car_object *)zend_object_store_get_object(
getThis() TSRMLS_CC);
car = obj->car;
if (car != NULL) {
RETURN_LONG(car->getCurrentSpeed());
}
RETURN_NULL();
}
I request you to please try the entire procedure given on the link once, so that you can understand my problem. If the code work fine by you that means i made some mistake then you tell me the procedure properly. So I will correct my mistake. I am new with PHP so probably I made some mistake because lack of knowledge.

I am waiting for your precious reply........

Thanks and Regards,
:)
Antrikssh....
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: Extension and Embeding in PHP

Postby faust » Wed May 09, 2012 12:22 am

sorry, but this is not php... I won't be able to help.
faust
New php-forum User
New php-forum User
 
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Re: Extension and Embeding in PHP

Postby Antrikssh » Thu May 10, 2012 8:57 pm

Hello,

I know that its not pure php thats why I use the name of the thread "Extension and Embedding in PHP". I used php with c++ code. In which I have ceated .so file of c++ code file then I called that .so file in php script. I have created the file but unbale to access by php script or by command prompt. But in the link that I have mentioned, wrote that It's possible. If any one who can help me in this please help me....

I waiting for your reply......

Thanks and Regards,
Antrikssh..... :)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: Extension and Embeding in PHP

Postby egami » Fri May 11, 2012 4:24 am

make sure that the webservice user has read access to your directory & files.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.