drazvzi741287 2014-10-18 09:01
浏览 18

比较数字和字符串[关闭]

I need your help figuring out how I can combine multiple if statements with different conditions. Below is the code that I'm trying to get to work.

<p><?php
     $age="25";
     $ID="prog5";

     if($age >= "16" && $age <= 32 && $ID == prog5) {
         print "Welcome to the Future of Systems";
     }
     else {
         print "Sorry, your ID isn't recognized by sync. Please click here for further  assistance.";
     }
?></p>

I would like the statement "Welcome to the Future of Systems" to be displayed only if $age is between 16 and 32 and if $ID is prog5, but the expressions I am using don't work.

  • 写回答

1条回答 默认 最新

  • dongxinxin7809 2014-10-18 09:03
    关注

    Change your if statement like this

    In short, string literals are delimited by quotes:

    if($age>=16 && $age<=32 && $ID=="prog5")
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)