CodeIgniter Forums
PHP syntax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: PHP syntax (/showthread.php?tid=29824)



PHP syntax - El Forum - 04-22-2010

[eluser]Iwasignited[/eluser]
Hello everyone.
I know this problem is not Codeigniter related but this forum is my first PHP programming forum (I dont know any other) so I decided to post it here, please help me.

I see some people write this
Code:
&$var
I'd like to ask what '&' means here?
And also
Code:
===
,
Code:
!==
.

Looking forward to hearing from you soon.
Thanks so much.

Sorry for my English


PHP syntax - El Forum - 04-22-2010

[eluser]danmontgomery[/eluser]
http://www.whypad.com/posts/php-what-is-the-ampersand-preceding-variables/193/
http://php.net/manual/en/language.operators.comparison.php


PHP syntax - El Forum - 04-22-2010

[eluser]WanWizard[/eluser]
Using an & means you're referring to the variable by reference: http://php.net/manual/en/language.references.php

=== means you not only want to compare the value, but also the type: http://www.php.net/manual/en/language.operators.comparison.php

!== means the same, but in a 'not' context.

So:
Code:
'1' === 1; // this is FALSE
1 === 1; // this is TRUE
'1' !== 1 // this is TRUE
1 !== 1 // this is FALSE

Compare with:
Code:
'1' == 1; // this is TRUE
1 == 1; // this is TRUE
'1' != 1 // this is FALSE
1 != 1 // this is FALSE



PHP syntax - El Forum - 04-23-2010

[eluser]Tominator[/eluser]
I show you example with &:
Code:
$a = 1;

function without($input)
{
return $input + 5;
}

function with(&$input)
{
return $input + 5;
}

echo without($a); // 6
echo $a; // 1

echo with($a); // 6
echo $a; // 6