2

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"


?> 
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
DollaBill
  • 239
  • 1
  • 3
  • 15

1 Answers1

-1

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.

mister martin
  • 6,197
  • 4
  • 30
  • 63