Using PHP in Android Webview - php

I created an app using PHP and it runs fine using the HTTP address in the Webview object.
When using locally, the PHP script does not work (putting all files in assets).
Is there a way for PHP pages to be loaded locally but to define the actual PHP part to be used at the webserver?
To clarify, all HTML content of the .php page will be used locally but when needed PHP code it will connect the webserver.
Thanks!

If you use a php content you should have Internet connection because php codes work on server side not local devices(some apk's install mysql+php in your android device but if you want to publish your apk this way wont work in all devices on local.)
Also if you want to make an offline project why dont you use javascript "To clarify, all HTML content of the .php page will be used locally"
Here you can download phpforandroid.apk to work on the local Click Here

Related

How to run php file in phonegap?

I am developing a mobile application in phonegap. My app works in a way that when a user submits a form, the data gets posted to a file called functions.php (present in the root folder) and functions.php parses data and sends to my rest application using curl. When I run this application in a web server, it works perfectly fine but when i run it in phonegap and post data to functions.php, instead of running functions.php as a function, it displays all the code of functions.php on the mobile screen and stops there. Does anyone know whats going on?
The situation you describe is what happens when you try to run a php file from a webserver that does not have php installed, so it sounds like you are trying to load the functions.php locally from within your phonegap app. Phonegap has its own webserver, which is not a php server, so it won't run php files. If you need to interact with php/sql/other remote stuff, you should be using ajax requests to interact with the remote (non-phonegap) server. https://forum.jquery.com/topic/how-do-i-get-ajax-working-with-phonegap

How to connect to external database for PhoneGap

I am using a simple log in page as a start page to my application. When details entered, the app will check details with an external mySQL database and come back to connect or give error message. I am doing all these via php and all files are with .php extension.
But how do I do this with PhoneGap? I read around and php is not recognized on PhoneGap and moreover I can no longer place my php files on the server side. All files are going to be compiled via phonegap build which would sit on the mobile device itself.
How do I connect to my external mySQL database for PhoneGap? Seen the following guide which does uses a php script. I tried and it is not working. I don't get how it would work anyway since I can't place my php script on a server side.
Guide

Does Twitter Bootstrap work with PHP?

I am new to Twitter Bootstrap and I included some simple PHP script to test and my browser (Chrome) won't read the php code. I have saved the file .html, .php, and tried .html.php. Is it that Twitter Bootstrap only works with client side, not server side apps, or is there a trick to get it to work with PHP?
Thanks
Does Twitter Bootstrap work with PHP?
Yes and no.
Bootstrap is entirely client side. It can be output by PHP (just like any other client side code) but has no special features for interacting with it.
my browser (Chrome) won't read the php code
PHP is a server side language. No browser parses PHP code. You need to access it through a web server that will execute the PHP and return the output to the browser. See also installing PHP.
Bootstrap is just some css and javascript. You can use it with a PHP app just fine. We do.
Use Microsoft WebMatrix 3 (installing php and Wamp servers is really very annoying)
Use Webmatrix IDE and then php and bootstrap will work just fine..

Webview in android able to run php

I am working on a Android Application that has web view where i need to load html, jquery and js and php also. Now i am able to load html jquery css javascript , But my problem is i am unable to load php in web view in offline is there any way to execute php in web view
Please Help Me Thanks In Advance
You almost certainly don't want to run PHP on your Android. But in case you do, then you would want http://code.google.com/p/php-for-android/. Better link: http://phpforandroid.net/
PHP is a server side language. It cannot run inside the browser. It helps you to build the dynamic web pages.
You can call any web page in the webview when you are online. it doesn't matter what is the server side language.
When you are offline, you cannot send request to any server. so no question of executing any page.
You can do it easyly with AndroPhp, just search it in Google play and install.
Its like WampServer for Php+Mysql. You should run it than just create your PHP project under www/ folder and call it from Android webview 127.0.0.1:80/yourproject
This way you you have local server on your Android, you shouldnt code in Java for Android all you can code in PHP. Maybe it is not a elegant way to code for Android but works !!

Jquery mobile php site and phonegap

I was trying to convert my website which ceated using jquery and its contain a few PHP page into Android application by using phonegap online converting tool, the app work on navigation but the PHP page will not work accordingly, so is there any way to work around?
You can't run php scripts on a mobile phone, you can convert all php scripts to html pages or you could load the whole website inside the webview.
place window.location = 'example.com' inside your deviceLoad event and make sure you whitelisted your website in your config.xml
What to place inside the config.xml can be found here.
https://build.phonegap.com/docs/config-xml
However, you need an internet connection to run the app, while the html pages doesn't require internet.

Categories