Welcome Guest, Not a member yet? Register   Sign In
URI - Passing text
#6

[eluser]alpar[/eluser]
i thin that the source of that problem above is that any string like 'r6v' for example will evaluate to 0 if you force a type. Here's an example:

$x = 'r6v';
$y = '6rv';
$z = '66';

(int) $x will be 0 , (int) $y will be 6, and (int) $z will be 66

in your case

$game_id = $this->uri->segment(3, 0);

if ($game_id == 0) {
show_error('No Game ID passed');
}


($game_id == 0) means that $game_id is compared to int 0, so it is automatically converted to an integer, since it starts with a letter, that is automatically a 0. if you want something similar to the above, use strings instead, use:

if ($game_id == '0') {

this way $game_id isn't converted to an integer.

Since PHP is loosely typed you really have to be careful with types, the fact that you don't declare variables with a strict type doesn't mean, that you will have nothing to do with types in your code.


Messages In This Thread
URI - Passing text - by El Forum - 08-22-2007, 06:05 AM
URI - Passing text - by El Forum - 08-22-2007, 06:16 AM
URI - Passing text - by El Forum - 08-22-2007, 06:58 AM
URI - Passing text - by El Forum - 08-22-2007, 07:35 AM
URI - Passing text - by El Forum - 08-22-2007, 07:45 AM
URI - Passing text - by El Forum - 08-22-2007, 08:36 AM
URI - Passing text - by El Forum - 08-22-2007, 08:38 AM
URI - Passing text - by El Forum - 08-22-2007, 08:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB