2

On shared hosting (on subdomain notes.jcubic.pl) I've try to use:

$host = gethostname();

but got n114.domenomania.pl (real server name) is there a way to get notes.jcubic.pl subdomain?

3 Answers 3

2

Are you looking lot the $_SERVER['HTTP_HOST']?

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, that was it I just found it.
Mark as answered please
I needed to wait 10 minutes SO rule.
0

For PHP >= 5.3.0 use this:

$hostname = gethostname();

For PHP < 5.3.0 but >= 4.2.0 use this:

$hostname = php_uname('n');

For PHP < 4.2.0 use this:

$hostname = getenv('HOSTNAME'); if(!$hostname) $hostname = trim(hostname); if(!$hostname) $hostname = exec('echo $HOSTNAME'); if(!$hostname) $hostname = preg_replace('#^\w+\s+(\w+).*$#', '$1', exec('uname -a'));

Comments

-1

you can use this also for connecting in localhost server $db_host = "localhost";

5 Comments

I need host so I can send email with a link to my app, I can't use localhost.
I think you want an online host ? try free hosting like /www.000webhost.com/
I've already have a host but I've got real server name and not my domain.
did you try this ? $host = gethostname(href="www.yourdomain");
I want to work with any domain not the one I have, it's open source project that should work anywhere. The domain can change. Also gethostname don't accept optional parameters the args is void and also php don't have keyword arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.