如何将 php 代码从 javascript 转移到 PHP?
所以我创建文本(php)编辑器,我想执行 PHP 代码而不刷新页面。 现在我使用 cookie 从 javascript 传输代码(抓取编辑器内容)。 然后颜色框打开,PHP 文件将 cookie 内容写入文件,该文件已包含在内。 还有一个问题:
是否有其他方法可以将 PHP 代码从 javascipt 转移到 PHP?或者还有其他方法来执行 PHP 代码吗?我知道有一个 AJAX,但我想传输更大的数据,包括 PHP 中出现的特殊字符(“、”、]、[、$ 等)。
是的,我仅在本地主机上使用它,仅用于教育目的: ) 抱歉我的英语不好,希望你能理解我。
So I create text(php) editor and I want to execute PHP code without refreshing page.
Now I use cookies to transfer code from javascript(which grab editor content).
Then color box opens and PHP file write cookie content to file, which is included.
And there is question:
Is there any other way to transfer PHP code from javascipt to PHP? Or any other way to execute PHP code? I know there is a AJAX, but I want to transfer a larger data including special characters(",',],[,$ etc.), that occur in PHP.
Yes, I use it only on localhost for education purpose only :)
Sorry for my english, I hope you understand me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AJAX适合发送大量代码。看一下 jQuery.post 和 jQuery.ajax。特殊字符通过 POST 请求不变。
确保将 php 设置
magic_quotes_gpc
设置为off
,因为此选项告诉 PHP 使用反斜杠转义任何特殊字符。AJAX is suitable for sending large amounts of code. Take a look at jQuery.post and jQuery.ajax. Special characters pass through POST-request unchanged.
Make sure you set php setting
magic_quotes_gpc
tooff
, as this option tells PHP to escape any special character with backslash.这次您仍然可以使用 AJAX,只是使用 POST。
尝试如下操作:
查看 https://developer.mozilla.org/en/ajax 来学习有关阿贾克斯的更多信息。
You can still use AJAX, only with POST, this time.
Try something like:
Look at https://developer.mozilla.org/en/ajax to learn more about Ajax.