html – Echo <style></style> in php-ThrowExceptions

Exception or error:

I am need to apply some style if my condition match. I have style like below

<style>
.adminCog {
    z-index: 3;
    position: absolute;
    right: 11px;
    top: 8px;
    display:none;   
}
</style>

I want apply this only if user_id is 1

like, I have tried

<?php
if($user_id ==1){
echo '<style>
.adminCog {
    z-index: 3;
    position: absolute;
    right: 11px;
    top: 8px;
    display:none;   
}
</style>';
}

but its not working as well not giving any error, let me know if someone can correct me. Thanks!

How to solve:

try like this

NOTE : Check what you get in $user_id.

<?php
    if($user_id ==1){
?>
<style>
   .adminCog {
       z-index: 3;
       position: absolute;
       right: 11px;
       top: 8px;
       display:none;   
   }
 </style>
 <?php
   }
 ?>

Leave a Reply

Your email address will not be published. Required fields are marked *