-1

Is it possible to use more that one scripting language in a single file of a web page? For example, I want to use python and ether php in my web page? Is it possible or not? I mean, have python a module to parse files like this? or any possibility on other web servers? Something like this:

[File Erfankam.ppp]

<php script part>
    Some thing in php
</php script part>

<html part>
    something in html
<html part>

<python script part>
    Some thing in python
</python script part>

<html part>
    something in html
<html part>

<perl script part>
    Some thing in perl
</perl script part>

I hope I was not wrong.

Erfankam
  • 380
  • 5
  • 15
  • 2
    You might want to re ask this question and talk specifically about what you are trying to achieve. Using multiple server side languages seems like a ridiculous idea but since we don't know what you actually want to do it's hard to comment. People normally use one SERVER side language and one CLIENT side language to present a web page. – aychedee Jun 20 '12 at 08:48
  • Thanks for you notation. I know it s so not normal to use more than one server side scripting language, But I just want to know is it possible? Actually I m working on a small web server project and I like to know about it that should I implement on my project or not? – Erfankam Jun 20 '12 at 19:36
  • You should consider going the other way: http://nodejs.org/ – Ishpeck Jun 20 '12 at 22:59
  • I cant understand. What do you mean? – Erfankam Jul 15 '12 at 15:57

1 Answers1

4

You could use Python to return a response that was a PHP script which was then further processed by the PHP processor. But it would always be a sequential process. So each stage would be handled by a different interpreter.

I cannot conceive of a good reason to do this.

On the other hand you could certainly serve a site that contained both PHP and Python scripts. Requests for different assets could be handled by either Python or PHP. This is easy enough to achieve when configuring a web server.

It would be possible to write some kind of parser that looked for specific tags and then processed the code inside those tags using the correct interpreter. But again not sure why you would want to do this. Some actual use cases might be interesting.

See this answer here for an example of how you can launch Python/Ruby from within a PHP script - How to run Ruby/Python scripts from inside PHP passing and receiving parameters?

Community
  • 1
  • 1
aychedee
  • 24,871
  • 8
  • 79
  • 83