0

I am trying to typecast a GET variable to int in internet explorer 11 (only) without success

URL ...&project_id=19

$tt= $_GET['project_id'] ; is 19 in debugger, as expected

$tt= (int) $_GET['project_id'] ; is 0

strlen($tt) is 2

mb_str_encoding($tt) is ASCII

In FF, the typecast works fine, same in older internet explorer.

anyone has ideas what is going on?

Klaus

opto
  • 57
  • 6

2 Answers2

0

I suggest not using cast. Instead use intval It's a bit slower than casting , see benchmark, but in my experience safer.

Community
  • 1
  • 1
Igor S.
  • 3,332
  • 1
  • 25
  • 33
  • "but in my experience safer" --- could you please elaborate? What would you say if I tell you they both use the same code internally? – zerkms Jan 20 '14 at 23:29
-1

oneneeds to reconvert from ASCII to UTF-8.

the following works:

$tt= (int) mb_convert_encoding($_GET['project_id'], 'UTF-8' );

Klaus

opto
  • 57
  • 6