duane9322 2014-04-24 20:35
浏览 45

为什么PHP从请求参数中删除前导零?

Im a noob to php and I don't understand why the leading character in my string, which is zero is being removed after I pass it through a url. Like so: http://sample.com/Sample/employee_select.php?emp=03

When I use $_GET to get the value it returns 3 instead of 03. How do i keep the leading zero?

this is NOT a duplicate of How to keep leading zeros in PHP integer.

MY CODE

 <?php 
 $emp = $_GET['emp']; 
 $tdat = $_GET['tdt'];

 echo $emp; //returns "3" instead of "03"


?> 
  • 写回答

1条回答 默认 最新

  • dongsuichi6529 2014-04-24 21:38
    关注

    I'm not able to reproduce your problem:

    echo $_GET['test'];
    // outputs 03
    
    echo '<br />';
    
    $temp = $_GET['test'];
    echo $temp;
    // outputs 03
    

    I think your issue is elsewhere. Possibly your PHP version / configuration, MOD Rewrite, or something else in your code that wasn't provided in your example.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度