Is there a way to know if a function is returning to a variable in PHP? -


I would like to know if there is a way in PHP to know that the function is still being said that it will return something Returning

  1. $ foo = bar ();

    For example, there is a way to find out when it happens:

    1. $ foo = bar (); P> It would be best if there is to know There is a way that if nothing like this exists within the bar () function - is it possible to implement it?

      I do not have to do this at the moment, but there is a simple use case:

        class model () {private $ foo = 0; Function bar () {$ foo + = 100; If (ReturnTourWireless) // & lt; ==== Return $ foo; }}  

      Then it can be used to get instantaneous value of $ foo (and yes, I know that I can use a setter, it just Is an example).

      Thanks in advance.

Just use this function properly when you are returnToVariable stable, Some expect expectations to be returned, otherwise there is no return value and your $ foo = bar () will be NULL .

  class model () {private $ foo = 0; Function Bar ($ return = false) {$ this- & gt; Foo + = 100; If ($ return) $ $ - foo; }} $ Model = new model (); $ Models & gt; times (); // $ model- & gt; Foo == 100 $ foo = $ Model- & gt; Bar (true); // $ model- & gt; Foo == $ foo == 200 $ foo = $ Model- & gt; times (); // $ model- & gt; Foo == 200; $ Foo == Tap; $ Models & gt; Bar (true); // $ model- & gt; Foo == 300; $ Foo == Tap;  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -