PHP include like iFrame

Discussion in 'PHP' started by mark7144, Sep 6, 2009.

  1. #1
    I'm including a website as an iFrame but I want to use PHP instead. The problem is, when you use the code below, the links within the external website cause the user to launch out of your website. In an iframe, when you click the links, everything stays within your website.

    Is there anyway to have this typical iframe behaviour using PHP?

    <?php  include("http://www.URL-to-my-shop.com") ?>
    Code (markup):
     
    mark7144, Sep 6, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First off you should change your code to file_get_contents instead of include for security reasons. Second, why won't you use an iframe? For what reason?
     
    premiumscripts, Sep 6, 2009 IP
  3. adithya

    adithya Well-Known Member

    Messages:
    568
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #3
    php include is used to include other php files whose functions are required in the current php file
    It will not act like a iframe substitute IMO
     
    adithya, Sep 6, 2009 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    Yes, I agree to file_get_contents as well. Probably iframe is not compliant in xhtml strict.
     
    Kaizoku, Sep 7, 2009 IP
  5. mark7144

    mark7144 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks guys, looks like I'm stuck with iFrames if you say I can have the pages that are linked stay within my website like an iFrame.

    The main reason I don't want to use an iFrame is the delay you get when it loads, I've tried using php instead and there is no delay, it's as if it's part of your own website.
     
    mark7144, Sep 8, 2009 IP
  6. autouch

    autouch Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you use file_get_contents, you will also get the <html><body> tags, which would screw up your markup if you're including it in the middle of an existing page.

    Also, DON'T use iFrames. Using iFrames is like programming HTML layouts with tables. It's cave-men web programming.
     
    autouch, Sep 8, 2009 IP
  7. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #7
    Then just parse it into a SimpleXML object then just grab the body.
     
    Kaizoku, Sep 9, 2009 IP