Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5945817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:44:05+00:00 2026-05-22T16:44:05+00:00

PHP: function is_homepage() { } if(is_homepage()) { echo ‘You are on the homepage’; }

  • 0

PHP:

function is_homepage()
{
}

if(is_homepage())
{
    echo 'You are on the homepage';
}
else
{
    echo 'You are not on the homepage';
}

Explanation:

is_homepage, should work in all these cases:

  • http://www.domain.com
  • https://www.domain.com
  • http://domain.com
  • http://domain.com/?param=value
  • http://domain.com/index.php?param=value

Where it shouldn’t work:

  • http://subdomain.domain.com
  • http://domain.com/otherfile.php?param=value
  • etc.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:44:06+00:00Added an answer on May 22, 2026 at 4:44 pm

    It depends of course on how your PHP script is laid out. Though the following solution would work in most cases:

    $_SERVER['SCRIPT_NAME'] == '/index.php'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

json_decode function is not part of PHP 5.1, so I cannot use it. Is
This example is from php.net: <?php function Test() { static $a = 0; echo
I want to create a PHP function that goes through a website's homepage, finds
Is it possible to have a PHP function that is both recursive and anonymous?
Below is an old PHP function I have for a dropdown list for users
Is there a Php function to determine if a string consist of only ASCII
Is there a php function that someone can use to automatically detect if an
Is there a PHP function that grabs the string in between two characters. For
Is there a php function to handle the encodings below? .replaceAll(\u00c3\u0080, &Agrave;) .replaceAll(\u00c3\u0081, &Aacute;)
Is there php function to remove the space inside the string? for example: $abcd=this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.