shows text only in main domain

Hello,
i need to show texts only at main home page like www.abcd.com, not at www.abcd.com/something/
This info will be inserted in index.php.
How can i do this?
tilmesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Oliver_DornaufCommented:
$_SERVER['SERVER_NAME'] holds the server name
$_SERVER['PHP_SELF'] holds the scrip name (incl. path)
0
tilmesAuthor Commented:
Hi Oliver,

would you please complete the code, which i can use it directly in script? like this kind of,
if ($sitename=abcd.com
{
      print "here is text";

}
0
Marcus BointonCommented:
Putting 2 and 2 together...

if ($_SERVER['SERVER_NAME' == 'abcd.com') {
     print "here is text";
}
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

tilmesAuthor Commented:
I get an error with this code.
0
tilmesAuthor Commented:
if ($_SERVER['SERVER_NAME' == 'abcd.com']) {
     print "here is text";
}

I used both www.abcd.com and abcd.com
but it do not print anything.
0
Marcus BointonCommented:
Oops, bad copy/paste, missed 1 char: It should be

if ($_SERVER['SERVER_NAME'] == 'abcd.com') {
     print "here is text";
}

If you want to see what your server thinks it is, just try:

echo $_SERVER['SERVER_NAME'];
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tilmesAuthor Commented:
Thankns Squinky,
it works.
0
tilmesAuthor Commented:
Hi Squinky,

there is an problem. The text shows also in second level of directories. It should not show in directory like abcd.com/test/
or abcd.com/text.html

I must show only under abcd.com
0
Marcus BointonCommented:
It's only showing because you're telling it to. If you don't want to display it, just don't include that code in files below the root level.
0
tilmesAuthor Commented:
The code must be included in file, It must be in index.php
The text must not show under other directories.
0
Marcus BointonCommented:
OK, in that case look at the parse_url() function - if the path is "/", print the stuff, otherwise don't:

http://www.php.net/manual/en/function.parse-url.php

$pi = parse_url($_SERVER['REQUEST_URI']);
if ($_SERVER['SERVER_NAME'] == 'abcd.com' and $pi['path'] == '/') {
     print "here is text";
}

If it doesn't work, read the docs some more.
0
tilmesAuthor Commented:
Hi Squinky,

it works fine now. Thanks.
Would you help me with perl for same work?
I have posted new quetion.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.