Using PHP and ASP in a single source file?

D

Dan S

I'm a software engineer but pretty naive about web programming/scripting.
I'm working with a server running Windows IIS. I have several ASP files and
several PHP
files (not developed by me) that all work fine on the server. There's a
little ASP that's to be put at the top of every page, which of course works
fine for the .ASP pages. Now, if I want
to include this same snippet of ASP code at the top of one of the PHP files,
is that possible?
If so, what would the extension of the "mainly PHP" file be? If the
extension is PHP, the ASP won't be recognized, and vice-versa. That's what
I'm experiencing anyway.

Thanks,

Dan
 
G

gorf

Dan S said:
I'm a software engineer but pretty naive about web programming/scripting.
I'm working with a server running Windows IIS. I have several ASP files and
several PHP
files (not developed by me) that all work fine on the server. There's a
little ASP that's to be put at the top of every page, which of course works
fine for the .ASP pages. Now, if I want
to include this same snippet of ASP code at the top of one of the PHP files,
is that possible?
If so, what would the extension of the "mainly PHP" file be? If the
extension is PHP, the ASP won't be recognized, and vice-versa. That's what
I'm experiencing anyway.

The way I understand it, a file's extension tells IIS to use a particular
DLL when working with a file. Unless you have a DLL that reads both ASP and
PHP, I doubt that you can do this. I don't think such a DLL exists either.

My suggestion is to find out which code is easier to convert to the other,
and settle with either PHP or ASP.
 
P

Paulus Magnus

gorf said:
The way I understand it, a file's extension tells IIS to use a particular
DLL when working with a file. Unless you have a DLL that reads both ASP and
PHP, I doubt that you can do this. I don't think such a DLL exists either.

My suggestion is to find out which code is easier to convert to the other,
and settle with either PHP or ASP.

You could always use one system to read the other page. For example, if
index.php needed something out of index.asp. You'd have a block of code in
index.php that used file() to read http://yourserver.com/index.asp and then
used a preg_match to hack the resulting bit of HTML from index.asp and then
you could just echo that block wherever you wanted it to appear. If you
placed some HTML comment strings around the bit of ASP you wanted to hack it
would make the whole snipping job a lot easier.

For instance,

<?
$file = file_get_contents ("http://yourserver.com/index.asp");
preg_match ("/<!--{SNIP HERE}-->(.*?)<!--{STOP SNIPPING}-->/s", $file,
$matches);
echo ($matches[1]);
?>

^^ Note: Untested code ^^

It's a bit of a kludge and results in two pages running through your IIS but
it may be a workaround for your duality issue for the moment.

Paul
 
M

Manitoba98

Or you could just use an <iframe>...
Paulus Magnus said:
gorf said:
files
and

The way I understand it, a file's extension tells IIS to use a particular
DLL when working with a file. Unless you have a DLL that reads both ASP and
PHP, I doubt that you can do this. I don't think such a DLL exists either.

My suggestion is to find out which code is easier to convert to the other,
and settle with either PHP or ASP.

You could always use one system to read the other page. For example, if
index.php needed something out of index.asp. You'd have a block of code in
index.php that used file() to read http://yourserver.com/index.asp and then
used a preg_match to hack the resulting bit of HTML from index.asp and then
you could just echo that block wherever you wanted it to appear. If you
placed some HTML comment strings around the bit of ASP you wanted to hack it
would make the whole snipping job a lot easier.

For instance,

<?
$file = file_get_contents ("http://yourserver.com/index.asp");
preg_match ("/<!--{SNIP HERE}-->(.*?)<!--{STOP SNIPPING}-->/s", $file,
$matches);
echo ($matches[1]);
?>

^^ Note: Untested code ^^

It's a bit of a kludge and results in two pages running through your IIS but
it may be a workaround for your duality issue for the moment.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top