Custom Fields
Support General Why does `echo rwmb_the_value` display a value twice?

  • Creator
  • #23997
    Resolved brandonjp

    I'm trying to actually understand why using echo produces different results when displaying values. I have num_of_items stored with a value of 6.

    * THE: <dd><?php rwmb_the_value('num_of_items'); ?></dd> displays 6
    * ECHO THE: <dd><?php echo rwmb_the_value('num_of_items'); ?></dd> displays 66

    * GET: <dd><?php rwmb_get_value('num_of_items'); ?></dd> displays nothing
    * ECHO GET: <dd><?php echo rwmb_the_value('num_of_items'); ?></dd> displays 6

    I've been studying the related docs: & - But still a little confused on how/why echo affects them.

Viewing 1 replies (of 1 total)
  • Author
  • #24005
    Long Nguyen


    For example:

    function yourStatus(){
       echo ' Done';
    echo 'Status ='. yourStatus();

    your output will look like this

    "DoneStatus ="

    instead of

    "Status = Done"

    Echo in a function is to send a value to the output buffer and echo the function to send it's output to the output.

    There is an echo inside the helper function rwmb_the_value() so the value will print twice. See more in the source code:

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.