Dynamic CD Site

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Dynamic CD Site

Post by basdog22 »

Is it possible to create a dynamic site that will run from a CD???

I thought that if i created an XML backend and run the scripts from within php itself it is possible.

anyone to correct me???
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

I've seen claims it can be done, but have never done it myself. Everyone I have ever seen turned out to be flash or javascript only...
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

I think it can be done but i need someone to onfirm.

I use DEV-PHP to code php and it has a button that when pushed the code is parsed ok. So if there is a way to do this on a CD....
User avatar
Fredix
Forum Contributor
Posts: 101
Joined: Fri Jul 18, 2003 2:16 pm
Location: Wehr (Eifel) Germany
Contact:

Post by Fredix »

I guess there is a "PHP-compiler" out there. You need one if I understood you right.
nufferkay
Forum Newbie
Posts: 24
Joined: Fri Nov 28, 2003 2:27 pm

Post by nufferkay »

But compiled PHP would be limited to a single platform, no? I suppose if you were only dealing with one platform that would be OK....
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

any way to send the php commands directly to the php.exe?
nufferkay
Forum Newbie
Posts: 24
Joined: Fri Nov 28, 2003 2:27 pm

Post by nufferkay »

*confused*

Is php.exe the Windows version of the PHP interpreter?
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

yes :D

BTW i know it is very difficult (the whole idea) but since there are programs that just send the php commands to the php interpreter i think it is possible to identify the OS the CD is running on and send the commands to the right interpreter.

can this be done or must i forget about it???
nufferkay
Forum Newbie
Posts: 24
Joined: Fri Nov 28, 2003 2:27 pm

Post by nufferkay »

If you can write (or maybe find online) a cross-platform executable that will detect the platform it's running on, and then use that to choose the interpreter, I don't see why not...

So you're basically trying to build a PHP app that you can run off a CD?
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

........no

I just want to know if this can happen.

maybe i write php and someone else creates this prog. (total noob when it comes to compile something) :roll: :roll: :roll:
nufferkay
Forum Newbie
Posts: 24
Joined: Fri Nov 28, 2003 2:27 pm

Post by nufferkay »

Well, here's a quick (and grossly oversimplified) crash course on how compiled code works:

Basically, most programs you run (such as .exe programs on Windows) are binaries (this means that all the commands that are executed are represented in the 0's and 1's that computer hardware understands).

To get a binary, you compile code from a higher-level language - C and C++ are two of the most common compiled languages. The compiler translates the C/C++ code into a binary that will be properly understood by a particular processor type and operating system. In many cases, you can use the same C or C++ code to create binaries for more than one platform, but each binary works only on the platform it was created for. Most applications are distributed as binaries rather than higher-level code.

PHP is an interpreted language. That means that instead of being distributed as a binary, each script is translated into binary each time it is run. The translating program is called an interpreter, and it is almost always a binary. There is a different interpreter binary for each platform, but they all interpret the PHP the same way. This means that you can distribute the same PHP script for any and every platform, because the interpreter will understand it the same way.

PHP's interpreter is usually a module (sort of like a plugin) for the Apache web server. However, there are a few apps out there that will interpret PHP without a server, or even compile it into binary form that can run on its own without a separate interpreter (although this is more commonly done with Perl). But of course, once you've compiled it into a binary, it is no longer effortlessly cross-platform, the way the initial script was.

If you wanted to distribute a PHP app on a CD without requiring anything else on the user's computer to be able to run, and that would work on most common operating systems and hardware, you would have to either:

a) compile a different binary for each platform and include them all on the CD

b) include a PHP interpreter for each platform on the CD, along with the plain-old PHP scripts you wrote.

Or, if you know that everyone who uses the CD will have Apache with PHP installed, you might be able to get it to use the scripts on the CD - but I'm not sure whether Apache is capable of doing this.

Hope that makes sense.

-N
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

thanks nuf...
Post Reply