Sunday, 15 April 2012

Use PHP class between 2 subdomains -



Use PHP class between 2 subdomains -

this question has reply here:

including remote file in php 2 answers

i have php class on subdomain want utilize in subdomain. can include on sec subdomain when phone call class, have "class not found" error.

on subdomain (http://a.mydomain.com), file: myclass.php:

class myclass { public function gettest() { homecoming 'hello world !'; } }

on subdomain b (http://d.mydomain.com):

include 'http://a.mydomain.com/myclass.php'; $class = new myclass(); echo $class->gettest();

error displayed: fatal error: class 'myclass' not found in /var/www/subdomainb/index.php on line 3

anyone has idee ?

you must include files using paths not urls. not sure file construction this:

include '/var/www/subdomaina/myclass.php';

also consider using namespaces.

php class subdomain

No comments:

Post a Comment