Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP if statements unsure where I'm wrong

I'm trying to specify that my logo appears on some pages and not on others, the only pages I do not want it showing on are the homepage and /index.php. I have the big logo appearing and disappearing as I want it and so I presumed I could just do the opposite for the small logo but I must be doing something wrong. Here is my current code:

<?php
$dunpage = $_SERVER['REQUEST_URI']; if ($dunpage != '/index.php' || $dunpage != '/') {?>      
<h1 class="small-logo">
<a href="/" title="<?php echo $siteName; ?>"><span><?php echo $siteName; ?></a>
</h1>
<?php } 
?>
<?php
$currentpage = $_SERVER['REQUEST_URI']; if ($currentpage == '/' || $currentpage == '/index.php') {?>
<h1 class="logo";>
  <a href="/" title="<?php echo $siteName; ?>"><span><?php echo $siteName; ?></a>
</h1>
<?php } 
?>
like image 596
user1021330 Avatar asked Jan 22 '26 07:01

user1021330


1 Answers

Instead of a logical OR in your first condition, you should be using a logical AND:

$dunpage = $_SERVER['REQUEST_URI']; if ($dunpage != '/index.php' || $dunpage != '/') {?> 
// Should be
$dunpage = $_SERVER['REQUEST_URI']; if ($dunpage != '/index.php' && $dunpage != '/') {?> 

Effectively, you were saying "act if the page is either not index.php, or not /." So in either of those cases, the opposite would be true. If it wasn't index.php, it could be /, for example.

like image 164
Michael Berkowski Avatar answered Jan 24 '26 23:01

Michael Berkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!