Welcome Guest, Not a member yet? Register   Sign In
uri->segment(n) - a question
#1

[eluser]soupdragon[/eluser]
A slightly strange problem here
url
...codeigniter/user/confirm/ACT/dGhlc291cGRyYWdvbkB3ZWJpdGFsLmRl

started with this which didnot work
if(($this->uri->segment(3,0) == 'ACT')&&($this->uri->segment(4,0) != 0)) {
$check = $this->usernorm_model->confirmnewuser($this->uri->segment(4,0));
}

so tying to find out why i've now ended up with

$thecode = $this->uri->segment(4,0);
if($thecode == 0) {
echo "wtf $thecode";
}

the weird bit is i get echoed out
wtf dGhlc291cGRyYWdvbkB3ZWJpdGFsLmRl

anyone got a quick explanation about this ? or am i being a bit dim today
#2

[eluser]webthink[/eluser]
Ignoring everything else this:

if($thecode == 0) {
echo “wtf $thecode”;
}

and getting wtf dGhlc291cGRyYWdvbkB3ZWJpdGFsLmRl is an impossibility. Are you sure you're accurately describing those lines of code and the output?
#3

[eluser]soupdragon[/eluser]
yep thats why i posted

tried again now and yep
$test = $this->uri->segment(4,0);
if($test == 0) {
echo "no wtf $test";
}

wtf dGhlc291cGRyYWdvbkB3ZWJpdGFsLmRl
Its avoidable with
$test = $this->uri->segment(4,'0');
if($test == '0') {
echo "no wtf $test";
}
--- nothing

I've already got round it just doesn't make and sense
#4

[eluser]xwero[/eluser]
That is very weird considering the segment method code is
Code:
function segment($n, $no_result = FALSE)
    {
        return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
    }
Nothing magical happens in that method.

what do you read when you do
Code:
var_dump($this->uri->segment(4));
#5

[eluser]soupdragon[/eluser]
it is weird defiantely

var_dump

string 'dGhlc291cGRyYWdvbkB3ZWJpdGFsLmRl' (length=32)
#6

[eluser]webthink[/eluser]
hmm well php is not a strongly typed language which means that a test for == 0 is exactly the same as == '0' whic is exactly the same as == FALSE. In order to test for type you can use === 0. This means that it doesn't matter if $this->uri->segment(4,0); passes back 0 in string form or integer... if the 4 uri param is missing $test == 0 will resolve to true. if($test == 0) is exactly the same as if($test == ‘0’)

I still maintain that what you've described is an impossibility. Especially given the fact that in your example you output the no wtf $test but the word 'no' is mysteriously missing.
#7

[eluser]soupdragon[/eluser]
I know its a problem, and yeah sorry when i deliberatlly just to annoy you personally didn't copy the word no

doesn't change the fact its definately reproducable by me here.

Avoiding the second parameter btw works.

if(($this->uri->segment(3) == 'ACT')&&($this->uri->segment(4))) {
$check = $this->usernorm_model->confirmnewuser($this->uri->segment(4));
}

no problems




Theme © iAndrew 2016 - Forum software by © MyBB