I want to display different html tags on the php page they are visiting, for example on the homepage and the computer shop basildon page I want the html tag <section class="testimonal-two pt-0"> and on all other pages I want the code <section class="testimonal-two">

Below is the code I have so far and it works for the computer shop basildon page but I'm unsure how to add the homepage into that code, the homepage is called index.php

<?php
if ($_SERVER["SCRIPT_NAME"] == '/computer-shop-basildon.php') {
    echo '<section class="testimonal-two pt-0">';
} else {
    echo '<section class="testimonal-two">';
}
?>

Just got it working with the following code

<?php $currentpage = $_SERVER['REQUEST_URI'];
                if($currentpage=="/" || $currentpage=="/index.php" || $currentpage=="/index" || $currentpage=="" || $currentpage=="/computer-shop-basildon.php" || $currentpage=="/computer-shop-basildon" ) {
                    echo '<section class="testimonal-two pt-0">';
                } else {
                    echo '<section class="testimonal-two">';
                }
?>

Glad you got it figured out. Here is a cleaner way of presenting the above code so it doesn't look so messy:

<?php

// Retrieve the current page
$currentpage = $_SERVER['REQUEST_URI'];

// Most pages have this CSS class
$class = 'testimonial-two';

// Array of pages
$array = array(
     '/',
     '/index.php',
     '/index',
     '',
     '/computer-shop-basildon.php',
     '/computer-shop-basildon'
);

// If the $currentpage is one of these things ...
if (in_array($currentpage, $array))
{
    // ... then overwrite the CSS class
    $class = 'testimonial-two pt-0';
}

echo '<section class="{$class}">';

I'll also mark this question as solved for you.

Thank you so much for the code Dani, that does look a lot cleaner and better than what I have

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.