html - PHP Conditional Tag -


i'm trying change color of svg when current page "work.php"

using following code

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

i consistently color '#c22533' if on "work.php"

how might correct php code?

try this:

<?php     echo (stripos($_server['php_self'], 'work.php')) ? 'white' : '#c22533'; ?> 

or, using $page variable:

<?php     $page = 'work';     echo (stripos($_server['php_self'], $page.'.php')) ? 'white' : '#c22533'; ?> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -