donglv9116 2015-10-26 19:00
浏览 44
已采纳

将变量传递给PHP中的另一个函数[重复]

In following function:

function dateSelect($monthname,$dayname,$yearname) {
   echo "rs: " . $monthname;    
  dropdownDateSelect($monthName, $dayName, $yearName);    
}

$monthname gets echoed out correctly. However, it is empty inside function dropdownDateSelect. I am not sure why. I am getting "Variable $monthName seems to be uninitialized" error message in Netbeans IDE.

function dropdownDateSelect($monthName, $dayName, $yearName){
  echo "rss: " . $monthName;
}

Now in"rss: $monthName", $monthName is empty.

Could you elaborate why this is happening and how I can pass $monthName to dropdownDateSelect function?

Thank you.

</div>
  • 写回答

1条回答 默认 最新

  • duanpang5583 2015-10-26 19:05
    关注

    You have to be aware of upper- and lowercase as they are not the same in PHP (see also the comments above). So this is how your function will work (with $monthName):

    function dateSelect($monthName, $dayName, $yearName) {
        echo "rs: " . $monthName;    
        dropdownDateSelect($monthName, $dayName, $yearName);    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题