1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Call php file in another domain/folder?

Discussion in 'PHP' started by tlbuckingham, Jul 4, 2008.

  1. #1
    I have been researching on how to call a php file located on another domain (same host server).

    I have added a include line to one of my websites which in turn I would like to read a xxx.php located in another domain but have not gotten it to work.

    I have tried the following:
    <?php include("/home/owernamehere/public_html/folder/callme.php");?>
    "<?php include ('http://www.domainname.com/callme.php') ?>"

    But it returns nothing. Any ideas if this is possible or if I'm missing something.

    Thanks.
     
    tlbuckingham, Jul 4, 2008 IP
  2. Thirtysixway

    Thirtysixway Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The first one could work, however the second one would probably not work.

    Most hosts configure PHP to not allow includes from outsite URLs. Plus, it would be like calling it in your browser, and you would get the results instead of the actual PHP code.

    What is the full location of your current file that has the include on it? Most hosts configure their servers as so you cannot include files from other user accounts/domains [for security reasons, so you can't mess with other accounts]
     
    Thirtysixway, Jul 4, 2008 IP
  3. tlbuckingham

    tlbuckingham Peon

    Messages:
    210
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    /home/myownername/public_html/folder/callme.php
     
    tlbuckingham, Jul 4, 2008 IP
  4. Ikki

    Ikki Peon

    Messages:
    474
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you're on a shared hosting, it's more likely that you won't be able to include any external file in your scripts due to security reasons.
     
    Ikki, Jul 4, 2008 IP
  5. dannet

    dannet Well-Known Member

    Messages:
    863
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    153
    #5
    Try it:

    <?php
    
    $xx = file_get_contents("http://www.domainname.com/callme.php");
    echo $xx;
    
    ?>
    PHP:
     
    dannet, Jul 4, 2008 IP
  6. alvas

    alvas Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you call php from other domain, you can only get the html result not the php script itself
     
    alvas, Jul 4, 2008 IP