What does $a = ($b >> $c) mean ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Joost
Forum Newbie
Posts: 2
Joined: Fri Jan 19, 2007 5:22 pm

What does $a = ($b >> $c) mean ?

Post by Joost »

Hello,

I came across a piece of PHP code that utilizes

Code: Select all

$a = ($b >> $c);
I have searched the tutorials and manual but couldn't find what the function is exactly.

Anyone that can help me out ?
Garcia
Forum Newbie
Posts: 5
Joined: Tue Jan 16, 2007 7:35 pm

Post by Garcia »

Here this may help.

http://www.php.net/manual/en/language.o ... itwise.php

Edit: Haha Ninja Space Goat :P
Last edited by Garcia on Fri Jan 19, 2007 5:40 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

http://us2.php.net/language.operators.bitwise

EDIT: DARN... too slow on the draw! :x
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Joost
Forum Newbie
Posts: 2
Joined: Fri Jan 19, 2007 5:22 pm

Post by Joost »

Ah, great help guys thanx!

Another one for you :roll:

What is the catch with feeding chr() integers past 255 ?

I mean, PHP takes chr(12034) without a complaint and returns an ASCII character. But how does it come up with the ASCII value for the character ?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Try this out:

Code: Select all

echo '<table>';
for($i=0; $i<3; $i++) {
	echo '<tr>';
	echo '<td>chr('.($i*255).')-chr('.((($i+1)*255)-1).')';
	for($j=0; $j<=254; $j++) {
		echo '<td>', chr($j), '</td>';
	}
	echo '</tr>';
}
echo '</table>';
For every 255 characters, chr() will start over at ascii(0) and continue rotating through the characters (e.g., 255=0, 256=1, 257=2,...)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

wtf? that printed out
Ï ƒå®†€Ð
:twisted:
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

This is what I'm getting with $i=10: http://www.evilwalrus.org/_public/testchr.php

edit: With $i<10, rather.
Post Reply