Q:

How to save echo statement in a variable which consists of javascript confirm box in it?

I have following code 
echo '<script type="text/javascript">confirm("Are You Ready To Restore ?");</script>';

Now a confirm box will appears as follows:

So when user click on ok the process will continue otherwise it will stop further processing as it cancel it.
I want to apply if condition on OK and cancel button . How to save this echo result in variable so that i can apply if condition on it .  

A:

How to save this echo result in variable so that i can apply if condition on it . 

You can't do that in one http request. You can put Javascript code in your PHP variables, display it but your PHP code will not get the answer to javascript prompt unless you initiate another request, usually via ajax. Or you can take that conditional code to Javascript completely. 
PHP is already asleep by the time JavaScript stats working. 

