PHP if语句返回相同的值

My code is always returning true when I'm comparing these variables. What am I doing wrong?

<?php
    $postuser = (integer)bp_activity_user_id();  //echos 1int(0)
    $posteduser = (integer)bp_activity_comment_user_id();  //echos 3int(0)

    if ( $postuser === $posteduser) {
       echo 'true';
    } else {
       echo 'false'; 
    }
?>

You need to use the function that RETURNs the value, not outputs it.

From docs I found for whatever this is,

bp_activity_user_id() X-Ref Output the activity user ID.

bp_get_activity_user_id() X-Ref Return the activity user ID.

return: int The activity user ID.

The function you are using echoes the variable, NOT returns it and therefore you can't set a variable with that function. Same for the this function.

bp_activity_comment_user_id() X-Ref Output the ID of the author of the activity comment currently being displayed.

bp_get_activity_comment_user_id() X-Ref Return the ID of the author of the activity comment currently being displayed.

return: int|bool $user_id The user_id of the author of the displayed

To use in an assignment, the function has to return a value. That's why your values are always (int)0: the functions you are using have no return value. So, it returns null which is cast to 0.

<?php
  $postuser = bp_get_activity_user_id();  

  $posteduser = bp_get_activity_comment_user_id(); 

//no need to cast: these functions return integers


     if ( $postuser === $posteduser) {
        echo 'true';
        } else {
        echo 'False'; 

Just use intval and == i think it should work and evaluate it fine

<?php     

      $postuser = intval(bp_activity_user_id());  //echos 1int(0)

      $posteduser = intval(bp_activity_comment_user_id());  //echos 3int(0)

      if ( $postuser == $posteduser) {
          echo 'true';
       } else {
            echo 'False'; 
       }

?>

Your prbolems are probably the wrong typecasts:

Change (integer) to (int)

$postuser = (int)bp_activity_user_id();  //echos 1int(0)
$posteduser = (int)bp_activity_comment_user_id();

http://php.net/manual/en/language.types.integer.php