php?

This is a discussion on php? within the Windows Programming forums, part of the Platform Specific Boards category; Is it possible to display (and process the php code) in a simple Win32 app? NOT MFC!!! i know mfc ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    9

    php?

    Is it possible to display (and process the php code) in a simple Win32 app? NOT MFC!!! i know mfc can handle html, but i want some dynamic pages. If so, how is this done? hopefully pure Win32 API if possible.

    Thanks

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Why not MFC?

    If you have a legacy app (in WIN32) just put the MFC code into a DLL and call from the WIN32 app.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    Quote Originally Posted by sniped22 View Post
    Is it possible to display (and process the php code) in a simple Win32 app?
    Displaying alone (as in a source editor) is very simple to do in Win32. However, you will need to install a php-enabled web server (Apache) to process php code.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Or call the PHP command line processor.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    12
    Quote Originally Posted by jverkoey View Post
    Displaying alone (as in a source editor) is very simple to do in Win32. However, you will need to install a php-enabled web server (Apache) to process php code.
    Another way to do it is to install Wamp5 on your computer.

    It emulates a Windows, Apache, mysql, and php5 server on your computer.

    It is very useful for seeing php code in your web browser.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    "Emulates"? It just installs and manages them, just like XAMPP.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    9
    What i mean is... how can i turn my win32 app into a web browser that supports php? I know it wont be easy

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Sure will be.
    Code:
    contents = get file contents of filename
    if filename ends with .php:
      contents = process(contents)
    
    
    function process:
      write contents to tempfile
      return output of command `php tempfile`
    That's the gist of it. Unless you find a way to embed a PHP interpreter in your app (not sure if that's supported), there's not even really another way to do it. Of course, the various server variables are not available to the PHP script, but then, it's not running on a server.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Jul 2007
    Posts
    9
    Quote Originally Posted by CornedBee View Post
    Sure will be.
    Code:
    contents = get file contents of filename
    if filename ends with .php:
      contents = process(contents)
    
    
    function process:
      write contents to tempfile
      return output of command `php tempfile`
    That's the gist of it. Unless you find a way to embed a PHP interpreter in your app (not sure if that's supported), there's not even really another way to do it. Of course, the various server variables are not available to the PHP script, but then, it's not running on a server.
    Do you know any specific (possibly built in) functions that can do that, or will i have to write my own. I am a complete novice.

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Search for popen(). That's the core element of it.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #11
    Registered User
    Join Date
    Jul 2007
    Posts
    9
    all of this seems too complicated, so i decided to move to mfc. I tried downloading ms vc++ 6.0 but when i run setup.exe it just hangs. Then it says my system doesnt have enough registry space, asks me if i would like to create more, i say yes, it says it's rebooting and on reboot it just doesnt work saying that the installation could not create more space. Does anyone have an MS visual c++ 6.0 download somewhere?

    I need to use msvc++ 6.0 because i dont know how to create an MFC app with VS express.

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You can't with Express. MFC is only distributed with the versions that cost.

    VC++6 cannot be legally downloaded, so you shouldn't ask on this board about it. You could browse a bookshop, though - some old books come with the educational version of VC++6 on a CD.

    Not that I'd recommend the program. It's completely outdated.

    I think that
    a) your plans are too ambitious for a relative newcomer to C++.
    b) MFC wouldn't help you at all in processing PHP. Displaying HTML is a different question, but one that doesn't touch this discussion.
    c) you should consider alternatives to MFC, like wxWidgets or GTK+. I know that GTK has a HTML display component, and I think wx has one, too.
    d) I still don't understand why you would want what you're doing in the first place. If you want to test PHP code, install a local server environment.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You could work out how to run CGI programs and use the PHP fastCGI build.

  14. #14
    Registered User
    Join Date
    Jul 2007
    Posts
    9
    Quote Originally Posted by CornedBee View Post
    You can't with Express. MFC is only distributed with the versions that cost.

    VC++6 cannot be legally downloaded, so you shouldn't ask on this board about it. You could browse a bookshop, though - some old books come with the educational version of VC++6 on a CD.

    Not that I'd recommend the program. It's completely outdated.

    I think that
    a) your plans are too ambitious for a relative newcomer to C++.
    b) MFC wouldn't help you at all in processing PHP. Displaying HTML is a different question, but one that doesn't touch this discussion.
    c) you should consider alternatives to MFC, like wxWidgets or GTK+. I know that GTK has a HTML display component, and I think wx has one, too.
    d) I still don't understand why you would want what you're doing in the first place. If you want to test PHP code, install a local server environment.
    not that i want to test php code, its that i want to be able to display php processed code in my apps.

  15. #15
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    What for? Are you writing a PHP IDE?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. combining c php and mysql
    By Thoth in forum C Programming
    Replies: 2
    Last Post: 01-30-2009, 09:55 AM
  2. PHP installation
    By ssharish2005 in forum Tech Board
    Replies: 8
    Last Post: 11-23-2007, 08:42 PM
  3. PHP on my Computer!
    By xxxrugby in forum Tech Board
    Replies: 4
    Last Post: 03-15-2005, 08:34 AM
  4. C++ and PHP communication
    By Korhedron in forum Game Programming
    Replies: 4
    Last Post: 01-12-2004, 05:37 AM
  5. PHP 4.3.0 released
    By codingmaster in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-30-2002, 06:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21