Explain it !!!!

I have found a code of php like that.
what is the Output of this code?

<?php

$x = 0;

echo -$x;

?>

Answer: -1

But i want to know why and how?????

with regards
masud

[####]
70-649 and 642-901 are the prerequisite criteria for 642-812 but students who have only done 70-431 or 640-822 usually don’t go for it.



3 Comments »

  1. nilesh says:

    simple , if it was -$x the its as 0-1 = -1, so

    try echo -$x + 1; will be 0

  2. shakil says:

    Dear masud I and ripon tested it.
    It actually shows 0 not -1.
    It shows -1 if you use ~$x.
    Its a bitwise binary not which negates all the bits of an integer,operates on bit level and negates all the bits of 0.

    Stay cool.
    Shakil@evoknow

  3. Masud says:

    I know that, it was actually a bug which has been fixed. Now it does as it should be. Thanks for this try and informing me that.

    hope you guys will continue to visit my blog.

    thanks

RSS feed for comments on this post. TrackBack URL

Leave a comment

viagra patent expire Viagra Sale viagra anxiety