我可以在PHP函数中添加javascript警报吗?如果有,怎么样?

我可以在PHP函数中添加javascript警报吗?如果有,怎么样?

问题描述:


可能重复:

如何从PHP调用JavaScript函数?

我可以在PHP函数中添加javascript警报吗?如果是,怎么做?

Can I add a javascript alert inside a PHP function? If yes, how?

假设您的意思是您希望在服务器时从浏览器弹出警报在你的PHP代码中达到某一点,答案是否。

Assuming that what you mean is that you want an alert to pop up from the browser when the server reaches a certain point in your php code, the answer is "no".

当服务器运行你的php代码时,没有与浏览器的联系(直到响应开始回来了)。在某些情况下,服务器可能会将内容流式传输回浏览器,在这种情况下,可能会有一些商定的约定,服务器要将内容流标记为立即提醒消息,但是我不认为这就是你在这里问的问题。

While the server is running your php code, there's no contact with the browser (until the response starts coming back). There are situations in which a server may be streaming content back to the browser, and in such a case it'd be possible to have some agreed-upon convention for the server to mark the content stream with messages to be alerted out immediately, but I don't think that's what you're asking about here.