javascript 我可以将 php 与 phonegap 一起使用吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4849674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 15:05:33  来源:igfitidea点击:

Can I use php with phonegap?

phpjavascriptcordova

提问by hitesh

I want to know whether I can use php file with phonegap or not?

我想知道我是否可以使用带有phonegap的php文件?

回答by Michal

No you cannot. Period. Not at all. However using phonegap you can load a website that runs PHP

你不能。时期。一点也不。但是,使用 phonegap,您可以加载运行 PHP 的网站

回答by Eren Tantekin

Since PHP is a server-side scripting language, your .php files will reside on the server side. You can however connect to php files on an external server and load the html it generates. If you do this, you won't be able to use the Phonegap API's though.

由于 PHP 是一种服务器端脚本语言,您的 .php 文件将驻留在服务器端。但是,您可以连接到外部服务器上的 php 文件并加载它生成的 html。如果您这样做,您将无法使用 Phonegap API。

Ideally, you would communicate the external php file by using ajax and retrieve information provided by it to load another local html file that is residing in your assets/www/

理想情况下,您将使用 ajax 与外部 php 文件进行通信并检索它提供的信息以加载驻留在您的资产/www/ 中的另一个本地 html 文件

回答by Daniel Kurka

you have to have your application logic in javascript to leverage phonegap. there is php interpreter on the phones just a webbrowser control execution your javascript.

您必须在 javascript 中使用您的应用程序逻辑才能利用 phonegap。手机上有 php 解释器,只是一个 webbrowser 控制执行你的 javascript。

For security purposes the javascript has be loaded from the index.html contained inside the app. (you can not navigate to another page)

出于安全目的,javascript 已从应用程序内包含的 index.html 加载。(你不能导航到另一个页面)

so if there isn't any fancy php to javascript compiler i would say no

所以如果没有任何花哨的 php 到 javascript 编译器,我会说不