How can I check if my function print/echo's something?

Grigory Ilizirov

I am often using echo to debug function code:

public function MyFunc() {

    // some code...
    echo "OK";
    // some code...

}

How can I check that my function print's/echo's something?

(pseudo code):

MyFunc();

if (<when something was printed>){
    echo "You forgot to delete echo calls in this function";
}
Rizier123

This should work for you:

Just call your functions, while you have output buffering on and check if the content then is empty, e.g.

ob_start();

//function calls here
MyFunc();

$content = ob_get_contents();

ob_end_clean();

if(!empty($content))
    echo "You forgot to delete echos for this function";

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How I can check if it something available in socket?

From Dev

How can I check my textarea at first and display something using JS after run the website immediately

From Dev

How can I check if my function is called with input from a pipe?

From Dev

How can I check my Android app's network consumption?

From Dev

How can I check if there's element in my arraylist that is not in the hashmap?

From Dev

How can I transform my dataframe in something readable by a boxplot?

From Dev

How can I do something before uninstalling my android app?

From Dev

How can I return to the beginning of my program if something goes wrong?

From Dev

How can I check if my AVPlayer is buffering?

From Dev

How can I check RAM of my laptop?

From Dev

How can I do something only for the first function call?

From Dev

how can I use function waiting to get something in swift 3?

From Dev

How can I hide a check box inside my web grid with an if function?

From Dev

how can i get my function to go through the dictionary and check if the key exists when user inputs

From Dev

How can I hide a check box inside my web grid with an if function?

From Dev

How can i create check function in postgresql?

From Dev

how can I type check this particular function?

From Dev

How can I convert google chrome's .keyIdentifier to something reasonable?

From Dev

How can I write something in a TextBox that's also used as a KeyBinding?

From Dev

How can I convert google chrome's .keyIdentifier to something reasonable?

From Dev

How can I check if my laptop's 3.5mm audio port works with a microphone?

From Dev

how can I check whether Intel's AVX is enabled on my computer?

From Dev

How can I check if my laptop's wireless card supports 802.11AC wifi?

From Dev

How can I inline my inner function?

From Dev

How can I inline my inner function?

From Dev

How can I limit my powerset function?

From Dev

can I assert at compile-time that a user of my function has done something?

From Dev

How can I perform a check on all check UITextField's in if condition

From Dev

Can I bind something else than 'this' for a function?

Related Related

  1. 1

    How I can check if it something available in socket?

  2. 2

    How can I check my textarea at first and display something using JS after run the website immediately

  3. 3

    How can I check if my function is called with input from a pipe?

  4. 4

    How can I check my Android app's network consumption?

  5. 5

    How can I check if there's element in my arraylist that is not in the hashmap?

  6. 6

    How can I transform my dataframe in something readable by a boxplot?

  7. 7

    How can I do something before uninstalling my android app?

  8. 8

    How can I return to the beginning of my program if something goes wrong?

  9. 9

    How can I check if my AVPlayer is buffering?

  10. 10

    How can I check RAM of my laptop?

  11. 11

    How can I do something only for the first function call?

  12. 12

    how can I use function waiting to get something in swift 3?

  13. 13

    How can I hide a check box inside my web grid with an if function?

  14. 14

    how can i get my function to go through the dictionary and check if the key exists when user inputs

  15. 15

    How can I hide a check box inside my web grid with an if function?

  16. 16

    How can i create check function in postgresql?

  17. 17

    how can I type check this particular function?

  18. 18

    How can I convert google chrome's .keyIdentifier to something reasonable?

  19. 19

    How can I write something in a TextBox that's also used as a KeyBinding?

  20. 20

    How can I convert google chrome's .keyIdentifier to something reasonable?

  21. 21

    How can I check if my laptop's 3.5mm audio port works with a microphone?

  22. 22

    how can I check whether Intel's AVX is enabled on my computer?

  23. 23

    How can I check if my laptop's wireless card supports 802.11AC wifi?

  24. 24

    How can I inline my inner function?

  25. 25

    How can I inline my inner function?

  26. 26

    How can I limit my powerset function?

  27. 27

    can I assert at compile-time that a user of my function has done something?

  28. 28

    How can I perform a check on all check UITextField's in if condition

  29. 29

    Can I bind something else than 'this' for a function?

HotTag

Archive