![]() |
& and `
Hi there,
I was actually wondering why - we also use && instead of & when combining to expressions like: PHP Code:
So I made a simple script to check out what an simple & would do: PHP Code:
´ Could someone explain why I get that funny result? And when to use a single & thx 4 reading :) Ou yeah and a function with a single & seems to work too: PHP Code:
|
I don't know why it gives you that.
But I know the way to accomplish what I think you want, which is replacing & with a dot, that way you get "ab" echoed. Also, another thing why it's 2 & and not 1 & is probably because you can use it with other expressions, like =& which would make a reference to the value of the other variable. |
The
& is a 'bitwise and' operator and is used in doing arithmetic on binary. For the example that you gave 'a' is binary 01100001 and 'b' is binary 01100010. The & means to set the result's bits to 1 where it is set in both, and to 0 otherwise. So the result is 01100000. Now, the echo statement converts the result to a string and the ASCII character for 01100000 (decimal number 96) is the backtick (`) character. |
wow, thats some cool stuff. Is there something like a pocket-salathe for my desktop - cause you seem to know everything :)
Thx to both of you |
Quote:
|
| All times are GMT. The time now is 12:48 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0