Include Class in File on another Domain

Discussion in 'PHP' started by hovesh07, May 6, 2008.

  1. #1
    Hi,

    I am writing a PHP app for domain1.com that would like to use a php file located on domain2.com

    
    domain1.com code:
    
    require_once('http://www.domain2.com/config.php');
    
    domain2.com/config.php code:
    <$php
    class ClsMe
    {
        // Here's a comment
        var $sName = '';
    
    	function ClsMe ($in_sName)
        {
    		$this->sName      = $in_sName;
        } // End of constructor
    } 
    
    $myvar = "Hi All";
    $>
    
    
    Code (markup):
    This works when I'm on the same domain and use just config.php.
    This doesn't seem to work when I go across domains.
    I am using 1and1 for a hosting provider for both domains.

    Help!
     
    hovesh07, May 6, 2008 IP
  2. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If it's on the same hosting account, you could [possibly] try including it via the absolute path. /path/to/account/www/domain2/ etc...
     
    Altari, May 6, 2008 IP
  3. Trusted Writer

    Trusted Writer Banned

    Messages:
    1,370
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Woudn't be better host your configuration file on domain2 and call such file from an include outside your main PHP coding?

    I do such thing sharing layout elements across multiple domains
     
    Trusted Writer, May 6, 2008 IP
  4. hovesh07

    hovesh07 Well-Known Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Woo hoo!
    Thanks for the suggestion.
    I'd still like to find a solution for across different servers/accounts.
     
    hovesh07, May 6, 2008 IP