Using PHP and ASP in a single source file?

Discussion in 'ASP General' started by Dan S, Sep 30, 2003.

  1. Dan S

    Dan S Guest

    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
     
    Dan S, Sep 30, 2003
    #1
    1. Advertising

  2. Dan S

    gorf Guest

    "Dan S" <> wrote in message
    news:blcf7i$ala9j$-berlin.de...
    > 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.

    --
    gorf
     
    gorf, Sep 30, 2003
    #2
    1. Advertising

  3. "gorf" <> wrote in message
    news:blcmc6$adg$...
    > "Dan S" <> wrote in message
    > news:blcf7i$ala9j$-berlin.de...
    > > 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.
    >
    > --
    > gorf
    >


    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
     
    Paulus Magnus, Oct 1, 2003
    #3
  4. Dan S

    Manitoba98 Guest

    Or you could just use an <iframe>...
    "Paulus Magnus" <> wrote in message
    news:bld9tq$qjd$...
    >
    > "gorf" <> wrote in message
    > news:blcmc6$adg$...
    > > "Dan S" <> wrote in message
    > > news:blcf7i$ala9j$-berlin.de...
    > > > 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.
    > >
    > > --
    > > gorf
    > >

    >
    > 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
    >
    >
     
    Manitoba98, Nov 1, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris
    Replies:
    1
    Views:
    13,644
    Oisin
    Mar 24, 2006
  2. Ted Zeng
    Replies:
    4
    Views:
    503
    Tim Arnold
    Oct 3, 2006
  3. Ted Zeng
    Replies:
    0
    Views:
    628
    Ted Zeng
    Oct 13, 2006
  4. Rajive Narain
    Replies:
    0
    Views:
    1,859
    Rajive Narain
    Sep 18, 2009
  5. Miquel Oliete
    Replies:
    4
    Views:
    170
    Miquel Oliete
    Mar 7, 2008
Loading...

Share This Page