PHP注意:使用未定义的常量 [英] PHP Notice: Use of undefined constant

查看:500
本文介绍了PHP注意:使用未定义的常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用后贴墙功能后,我收到一条奇怪的错误消息.它确实成功贴在墙上,但是我遇到了一个非常奇怪的奇怪错误.

I have a strange error message after using the post to wall function. It did successfully post to the wall however i got a very weird strange error.

[2015年12月28日星期一12:47:36] [错误] [客户端5.29.224.120] PHP注意:使用未定义的常量女性-在/datas/vhosts/nf.com/httpdocs/agence1948/中假定为女性"第178行的result.php,引荐来源网址: https://nf.com/agence1948/question.php [2015年12月28日星期一12:47:36] [错误] [客户端5.29.224.120] PHP注意:使用未定义的恒定公字符-/datas/vhosts/nf.com/httpdocs/agence1948/result.php中假定为公"在182行上,引荐来源网址: https://nf.com/agence1948/question.php

[Mon Dec 28 12:47:36 2015] [error] [client 5.29.224.120] PHP Notice: Use of undefined constant female - assumed 'female' in /datas/vhosts/nf.com/httpdocs/agence1948/result.php on line 178, referer: https://nf.com/agence1948/question.php [Mon Dec 28 12:47:36 2015] [error] [client 5.29.224.120] PHP Notice: Use of undefined constant male - assumed 'male' in /datas/vhosts/nf.com/httpdocs/agence1948/result.php on line 182, referer: https://nf.com/agence1948/question.php

我使用此代码

<?php if($_SESSION['score'] >= 15 && $_SESSION['score'] <= 20): ?>
		
		<?php if($_SESSION['gender'] == female): ?>
			<img src="img/Refaeli.jpeg"/>
		<?php endif; ?>
		
		<?php if($_SESSION['gender'] == male): ?>
			<img src="img/avidan.jpg"/>
		<?php endif; ?>
		

有人知道出什么问题吗?

someone knows whats is the problem?

谢谢

推荐答案

malefemale是字符串,因此请用引号引起来!

male and female are strings, so enclose with quotations!

应该是:

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

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

这篇关于PHP注意:使用未定义的常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆