How to integrate C in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

How to integrate C in PHP

Post by shaky »

How to integrate C in PHP

dear friends,

I really really need help on how i can integrate c program in php. I need some example on how to do it. I've try to read the php manual on php.net but i can't understand it.

->My project- developing a web-based system (written in php) for a
consultancy company and implementing ECC algorithm (encryption) (written in C) to the company's critical data.

Please!!!

Thanks a lot in advance.

-shaky-
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

It depends on how your C program receive and output the data...
Program execution functions, Process control functions, pipes, shared memory... it's up to you to choose.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

or maybe even writing an extension. The php source code package provides a lot of examples of them.
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

Post by shaky »

hi volka!

*******************************************************
or maybe even writing an extension. The php source code package provides a lot of examples of them.
*******************************************************

how do i write an extension?
where do i find the php source code package?

thanks
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

http://www.php.net/downloads.php

^ There, hope that helps.

-Nay
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

all extensions are in the directory ext/
start by analyzing a simple extension like tokenizer
http://www.php.net/manual/en/zend.php will help you understand esp. the macros.
There's also a script ext_skel (or ext_skel_win32.php) that helps you creating your own extension
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

Have you looked at the pear package Inline_C?

Or if you want to run the compiled program in php, then you can probably use [php_man]shell_exec[/php_man]
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

Post by shaky »

Can anybody explain to me step by step what i have to do to integrate C in PHP 'coz i've try to read the php manual u guys suggested, especially
http://www.php.net/manual/en/zend.php. It is to complicated for me to understand especially now i'm running out of time.

Actually, my project is to develop a consultancy info system, where user have to enter their username and password to use the system (in php environment). So then i want to encrypt the password using an algorithm called ECC in C language. That is why i need to integrate C in PHP.

Do you think that's possible? i mean i want to sent the password which user entered to the C program to be encrypt and then send it back to the php program to compare it with the password in the database.

Please help me! I need to know what setting i have to do?
Can i just use Borland Turbo C++? I've try to run simple extension tokenzier using Turbo C++ as suggested by mr. volka, but there are so many error like "unable to open include file PHP.h"!

What can i do? Is there any setting that i need to do first?
Post Reply