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 5844585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:18:50+00:00 2026-05-22T12:18:50+00:00

I want to echo something if the subdomain is not mobile and the file

  • 0

I want to echo something if the subdomain is not “mobile” and the file name is not “design” or “photo”, so echo if (not “mobile” and not “design”) or (not “mobile” and not “photo”).

The code I wrote is:

<?php
    if ( ($subdomain != mobile) && ($currentFileName != design || $currentFileName != photo) ) {
        echo ('code')
    }
?>

but it doesn’t like the compound statement. if i just do ($subdomain!=mobile) it works; if i just do ($currentFileName!=design) it works; and if i just do ($currentFileName!=photo) it works….
The above code doesn’t result in an error…it just doesn’t do anything.

Is there a particular way to compound/group the statement that I’m just not getting? I feel like this shouldn’t be difficult (and I’ve done much more complex things with php without this much trouble…).
I modelled my statement after this: http://www.php.net/manual/en/control-structures.if.php#101724

Thanks!

EDIT:
fyi:

$subdomain = implode(array_slice(array_reverse(explode('.', $baseURL)),2)); //resolves to "test"
$basename = basename($_SERVER['REQUEST_URI']); //resolves to "design.php"
$currentFileName = basename($basename, ".php"); //resolves to "design"

the new problem is that everything in the subdomain “mobile” is now being caught, so no pages in it are getting the “code” from echo (even the ones not ‘design’ or ‘photo’).

the most recent code I tried was:

if ( ($subdomain != 'test' && $currentFileName != 'design') && ($subdomain!='test' && $currentFileName != 'photo') ) {
    echo ('ajax code');
}

but still no dice 🙁

  • 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-22T12:18:51+00:00Added an answer on May 22, 2026 at 12:18 pm

    There’s a flaw in your logic. You most likely want && not ||. If you think about the statement for a minute it will become apparent. Let’s say the following scenario: $currentFileName is ‘design’. It will pass since it’s not ‘photo’. If we make $currentFileName equal ‘photo’ it will still pass since it doesn’t equal ‘design’.

    EDIT:
    And PLEASE use quotes when comparing strings. PHP will attempt to find a constant with that name first, then assume it’s a string because it doesn’t find one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to echo out each date in my Array within a PHP file.
I want to echo something to a file, for example: aaaa bbbb man echo
I want to echo a full name from my MySQL database in my header.
I want to use echo to add data into a text file progressively. I
I want to make this form: echo '<form method=post action=ratinghandler.php style=width: 250px> <input type=hidden
If you want to overwrite a file with Bash, this is easy echo Hello
I am trying to do something really simple with php but I can not
Possible Duplicate: Compare multiple values in PHP I want to do something like this
XML file contains: <list1> <dzial> <ofert> <param name=surname type=text>Something</param> <param name=number type=text>4234-343-3</param> </ofert> </dzial>
I want to echo part of an array 'name' and then have a submit

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.