PHP Notice: Use of undefined constant [duplicate]

我与影子孤独终老i 提交于 2019-12-02 15:06:00

male and female are strings, so enclose with quotations!

It should be:

<?php if($_SESSION['gender'] == 'female'): ?>
            <img src="img/Refaeli.jpeg"/>
        <?php endif; ?>

        <?php if($_SESSION['gender'] == 'male'): ?>
            <img src="img/avidan.jpg"/>
        <?php endif; ?>

male and female should be enclosed with quotes as they are strings. E.g

<?php if($_SESSION['gender'] == 'female'): ?> OR

<?php if($_SESSION['gender'] == 'male'): ?>

Two error in your code

1) You need to end first if condition

2) male and female inside quotes for comparision .Otherwise it is treated as constant

<?php if ($_SESSION['score'] >= 15 && $_SESSION['score'] <= 20): ?>

    <?php if ($_SESSION['gender'] == "female"): ?>// use quotes
        <img src="img/Refaeli.jpeg"/>
    <?php endif; ?>

    <?php if ($_SESSION['gender'] == "male"): ?>// use quotes
        <img src="img/avidan.jpg"/>
    <?php endif; ?>
<?php endif; ?>// end first condition
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!