#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I have some C functions (compiled and working in c) which i want to use in PHP. However, i dont know how to go about it. can anyone help me?? please dont tell me i have to code the entire thing all over again in php. cud u reply fast???
  2. #2
  3. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    What do these C functions do? Can they be called from the command line? (if so, then just use exec("/path_to_file/your_function $arguments1 $arguments2 etc..."), or one of the other PHP execution functions. See http://www.php.net/manual/function.exec.php ;The function you use depends on what you need to do with the output. This might be a quick & ugly solution, but it sounds like you are in a hurry.

    Remember, PHP executes, reads, and writes files as user 'nobody', so watch your file perms.

    [This message has been edited by rycamor (edited October 31, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    thanks a lot. i can try this - however, they are not command line executable at the moment. more-over i have to get some return values from the functions. what do i do?? ( i did see the link and about the return_var variable).
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    15
    if your c program reads and writes to STDIN and STDOUT respectively, you could use a pipe instead... ie popen() etc

    just a thought - don't get the impression that i've ever done anything like that before
  8. #5
  9. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    There's got to be some way to serialize your values to a string, return as output, and unserialize the string at the PHP end.
    Also the eval() function might come in useful here.

    Maybe no need to serialize; just pack everything into a string that can be eval()ed at the other end. Shouldn't be too hard .
  10. #6
  11. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    why don't u create a new module..
    or far more easier.. add it to for
    example the strings module
    see string.c

    it's very easy to add something..
    then just recompile and user ur functions

    and.. btw, what functions are these ?

    ------------------
    Greetings lewi

Similar Threads

  1. php & macintosh, urgent plz
    By rehab_shouman in forum PHP Development
    Replies: 2
    Last Post: January 28th, 2004, 08:34 PM
  2. Functions page - php, mysql
    By liberate in forum Project Help Wanted
    Replies: 1
    Last Post: January 22nd, 2004, 11:44 AM
  3. Javascript and PHP: urgent
    By tanvirgaus in forum JavaScript Development
    Replies: 3
    Last Post: January 20th, 2004, 12:53 PM
  4. URGENT multiple selections in list ,processed with PHP & MYSQL
    By jt-developer in forum PHP Development
    Replies: 1
    Last Post: January 15th, 2004, 06:37 AM
  5. Certain functions not working with PHP 4.3.3
    By napoleon_bona_p in forum PHP Development
    Replies: 2
    Last Post: January 14th, 2004, 02:02 AM

IMN logo majestic logo threadwatch logo seochat tools logo