using PHP and C#

Discussion in 'PHP' started by alarik, Dec 5, 2006.

  1. #1
    I am interested if it is posible to use PHP to run external .exe files,and another thing,I am interested if there is any way for PHP/MySQL to execute a C# external file and output it's result.I really could use some heavy C# programing in HTML.If PHP is not the answer please tell me what I can use.
     
    alarik, Dec 5, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I am interested if it is posible to use PHP to run external .exe files,and another thing,

    yes, exec(), system(), shell_exec(()

    I am interested if there is any way for PHP/MySQL to execute a C# external file and output it's result.I really could use some heavy C# programing in HTML.If PHP is not the answer please tell me what I can use.

    I don't know, but not php :(
     
    krakjoe, Dec 5, 2006 IP
  3. SEO Jeff

    SEO Jeff Active Member

    Messages:
    534
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Only way I believe to do that is with a ActiveX control because what your doing really is launching a client-side application and the fact that both .NET and PHP I'm sure have some sort of Security Sandbox where they won't let you have full trust thus not going to let you run a exe from the server.
     
    SEO Jeff, Dec 5, 2006 IP
  4. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #4
    I think that you might be able to use PHP and C on a windows platform together. But I am just guessing this, never tried, or read something about it...

    Someone here might have a better answer. :)
    Bye :)
     
    JEET, Dec 5, 2006 IP
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    krakjoe is right about exec / system / etc. It should return the output to PHP for you to do what you want with it.

    I'll expand on JEET's reply a little, too. Firstly, PHP + C is possible. You write a PHP extension in C and then just load it through the PHP.INI file to call from PHP. In exactly the same way that adding the mysql.dll file to PHP.INI allows you to make mysql function calls, your extension would allow you to make the function calls that you need, too. You would do all of the hard work in the C extension and then return the output (or whatever) to PHP. You will need to do some reading up on writing extensions, though. I haven't done it for years but it all came to me in a Eureka moment. It can be tweaked to let you run C++ DLLs, too. You can do this on all platforms that support PHP.

    If you'll only be running it on Windows, you could look into the W32API extension. It should allow you to 'hook' into your DLLs that way. I've never used it, so I couldn't tell you how easy it is.
     
    TwistMyArm, Dec 5, 2006 IP
  6. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #6
    TwistMyArm, C# and C are not the same thing.
    alaric, you need Windows hosting to run .NET apps , so instead of PHP take a look to the ASP.NET - a Microsoft server-side thing.
     
    wmtips, Dec 5, 2006 IP
  7. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    wmtips, I know that. That's why in my reply I said that I was expanding on what JEET had to say (which although didn't address the question exactly, well, it did provide a bit of information).

    Anyway, wmtips is right: for the details you've given it's probably easier just to use ASP.NET. I mean it all depends on what exactly you're doing (who knows, there may already be an extension for what you want to do) as well as what percentage of the overall site 'work' will be done inside these apps that you want to call.
     
    TwistMyArm, Dec 5, 2006 IP
  8. wormy

    wormy Active Member

    Messages:
    1,112
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #8
    You can run C# scripts on linux and call them from PHP using the mono suite from Novell I believe.
     
    wormy, Dec 24, 2006 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #9
    PHP can communicate any linux oriented programming language.

    You can use SWIG to do that.

    Peace,
     
    Barti1987, Dec 24, 2006 IP
  10. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #10
    thanks a lot,you've been very helpful
     
    alarik, Dec 25, 2006 IP