0

The var $bt_ent contain the letter 'V' or 'L', so why the visibility of my td stay empty? My Ternary Logic isn't good ?

My code :

<?php $bt_ent = $this->depotInformation->bt_entite->getValue() ?>
<td style="visibility : <?php $bt_ent = 'V' ? 'visible' : 'hidden'; ?>">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;" >

The DevTools :

<td style="visibility : ">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;">

Thanks

2 Answers 2

2

You are assigning ( = ) instead of comparing ( == ). Also an echo is missing to actually output the result.

<?php $bt_ent = $this->depotInformation->bt_entite->getValue() ?>
<td style="visibility : <?php echo $bt_ent == 'V' ? 'visible' : 'hidden'; ?>">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;" >
2
  • So if you want to print the resolut of a ternary logic you have to put an echo before the condition? Alright thank you a lot! Dec 2, 2019 at 14:39
  • Everything you want from PHP to be in your final HTML-Code must be printed out in any way.
    – Hecke29
    Dec 2, 2019 at 14:40
0

you are assigning $bt_ent instead of printing it.

change

<?php $bt_ent = 'V' ? 'visible' : 'hidden'; ?>

to

<?php echo ($bt_ent == 'V' ? 'visible' : 'hidden'); ?>
1
  • Not entirely sure what echo 'V' ? 'visible' : 'hidden'; is meant to do.
    – Nigel Ren
    Dec 2, 2019 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.