PHP条件标签[关闭]

I'm trying to change the color of an SVG when the current page is "work.php"

Using the following code

<?php if($page=='work'){echo 'white';} else{echo '#C22533';}?>

I consistently get the color '#C22533' even if I am on "work.php"

How might I correct this PHP code?

use

<?php
    if(pathinfo(__FILE__, PATHINFO_FILENAME) == 'work')
    {
        echo 'white';
    }
    else
    {
        echo '#C22533';
    }
?>

try this:

<?php
    echo (stripos($_SERVER['PHP_SELF'], 'work.php')) ? 'white' : '#C22533';
?>

or, using your $page variable:

<?php
    $page = 'work';
    echo (stripos($_SERVER['PHP_SELF'], $page.'.php')) ? 'white' : '#C22533';
?>