DISQUS

DISQUS Hello! php programmer of bangladesh is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Explain it !!!!

Started by masudiiuc · 9 months ago

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 ... Continue reading »

3 comments

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

    try echo -$x + 1; will be 0
  • 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
  • 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

Add New Comment

Returning? Login