$ mobile = table_phone(); 即使不拨打$ mobile也会立即显示

can anyone explain me why is my function value shown on a page immediately even without putting <?php echo $mobile; ?>

I just type this part:

<?php $mobile = table_phone(); ?>

and phone number gets displayed, but not where I want it. Not where I call

<?php echo $mobile; ?> 

I tried to use other function like osc_user_phone_land() which is part of the osclass core and that one is working fine, but calling for mobile_phone, which is actually part of the plugin is not working properly.

Any ideas? My coding knowledge is quite limited so it might be a super simple fix..

Here is the more of the code:

<div class="description-right">
     <?php 
        $mobile = '';      
        if($mobile == '') { $mobile = table_phone(); }      
        if($mobile == '') { $mobile = __('No phone number', 'OSCLASS'); }      
     ?> 
   <div class="mob-wrap">

     <div class="mob-top">
       <span><i class="fa fa-phone"></i><?php _e("Contact", 'OSCLASS'); ?>     </span>
     </div>

     <div class="mobile-show" rel="<?php echo $mobile; ?>">
      <span>
          <?php 
            if(strlen($mobile) > 3 and $mobile <> __('No phone number', 'OSCLASS')) {
              echo substr($mobile, 0, strlen($mobile) - 3) . 'XXX'; 
            } else {
              echo $mobile;
            }
          ?>
      </span>
     </div>     

   </div>

function from helper.php

<?php
function get_realestate_attributes(){
    $locale = osc_current_user_locale();
    $return = array('attributes','other_attributes','special','lang','tel_num');
    $detail = ModelRealEstate::newInstance()->getAttributes( osc_item_id() );
    $keys = array_keys($detail) ;
    if(count($keys) == 1 && $keys[0] == 'locale' && is_null($detail[0]['locale']) ){
        // nothing to do
        return false;
    } 

    if(@@$detail['locale'][$locale]['s_number'] != "") {
        $return['tel_num']['year'] = array(
                 'label' =>__('Telephone number', 'realestate_attributes')
                ,'value' => @@$detail['locale'][$locale]['s_number']
            );
    }
    return $return;
}


function table_phone(){ 
    $detail = get_realestate_attributes();
    if($detail['tel_num']){
    ?>     
        <span>
        <?php
            foreach($detail['tel_num'] as $item){
                echo ''.$item['value'].'';
            } 
        ?>
        </span>

    <?php
    }
}

Change your table_phone() method like this :

function table_phone(){ 
    $detail = get_realestate_attributes();
    $result = '';

    if($detail['tel_num']) {
       foreach($detail['tel_num'] as $item){
            $result .= $item['value'];
        } 
    }

    return $result;
}  

Now you can do $mobile = tab_phone();, you'll not have any output.
And when you want display it, use echo $mobile.

Because I've removed the <span> in your method, you can juste add it manually like :

<span><?php echo $mobile; ?></span>

If you cannot change the method, use a closure like the following :

if($mobile == '') { 
    $mobile = function() { 
        table_phone(); 
    };
}

And everywhere you call $mobile, use :

<?php $mobile(); ?> // Result is displayed