I
I
ILoveYAnny2016-03-29 23:48:23
PHP
ILoveYAnny, 2016-03-29 23:48:23

How to pass the value of a variable from method A to method B in a class?

Hello, please help me understand. Googled Googled, but never got to a working solution.
There is a class, it has 2 methods, one creates a template and displays it to the user, the second sends this template after confirmation.
That is, with the first Ajax request, we generate a template, show that if the user clicks OK, then the send method is called. And here I can’t transfer the previously generated template into it.
Of course, in the second Ajax, you can send markup from the client side, which we show to the user, but I think this is wrong. I want everything to happen on the server.
That is, the template was generated, saved to a variable, then a minute later another method was called, the template was passed to it, and the letter was sent. Can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-03-30
@ILoveYAnny

class A {
  function someFunction() {
  $var = шаблон;
  return($var);
  }

  function anotherFunction() {
  $var2 = someFunction();
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question