Use PHP in UIWebview on iPhone - php

Is this possible??
If i wanted to put a UIWebview into my app, could i make mysql db calls and use other PHP functions?

You can tell your UIWebView to load a URL of a file sitting on a web server. That URL can be to a PHP page that can do... well, anything a PHP page can do. Database stuff, etc.
But that's happening on the SERVER. PHP is a SERVER-based technology. PHP doesn't run on the BROWSER, which is what a UIWebView is.

No. Think of the UIWebView as a web browser, as opposed to a web server. It is effectively a way of embedding Mobile Safari into your application.

Related

Can PHP be accessible offline?

My Employer would like me to take a web application written entirely in PHP to be accessible while offline. (it has to be accessible by an ipad without internet connection.)
I have tried the following things:
http://solesignal.com/draftcode/
http://blog.smartbear.com/codereviewer/15-code-editors-for-the-ipad-for-free-or-very-cheap/
https://itunes.apple.com/us/app/offline-pages-save-complete/id364859644?mt=8
Before I'm going to spend any money i have to be 100% positive it works.
Does anyone know how i can achieve this?
What do you mean by offline?
If you're looking to embed the server within your app, you're out of luck, it's not possible nor allowed. However if you want to run a local environment in your computer, take a look at MAMP
Knowing more about Mike's question, He's trying to run a website/webapp made in PHP offline/stand-alone on iOS devices.
As PHP is a pre-processor, this is not possible without a seperate server doing the magic. Depending on what this application has to do, I suggest you try to re-make the webapp so it does not use PHP. A lot of the things done with PHP can also be done client-side with JavaScript.
If you require more sophisticated things, try looking into the Meteor Framework. It supports PhoneGap exportation natively so the applications can run stand-alone on mobile devices as apps.
EDIT: If you can use an android device, you CAN run a PHP server on the same device as the pages are displayed because android is simply more open then iOS. If you're not willing to re-write the PHP code to JS, grab an android tab and use a PHP server package for android like this or another one that does include a MySQL server like this one

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..

Using phonegap, is there a way for an Android device to communicate with PHP?

I have a php page which connects an API and gets information back which can then be displayed.
I'd like to turn this into an app for Android. I've heard of PhoneGap, which I know uses javascript, html, and css. I know javascript is capable of calling php files, but I am unsure how or if its even possible to call a php file from an android device. I'm not sure if android browsers can handle php, or what the deal is with them. So if you have any information on that, I'd appreciate it.
I'm also willing to rewrite the API call in javascript, but I don't think thats possible. If you think differently, please let me know what you're talking about.
Android cannot talk directly to PHP. What phonegap, javascript, etc.. are doing is simply issuing HTTP requests that happen to be handled by a PHP script.
The PHP code will execute, output some data (json, html, xml, gif, jpg, etc...) and send that out as a the HTTP request's reply.
PHP is just a server side language so it doesn't matter if your browser "can or cannot" handle it, only HTML is returned (unless you set a different content-type).
You may be worth while looking into REST style JSON api's which would allow a XMLRequest to be sent to. Have a look at this document
Theres also a nice tutorial here which shows how to call a REST API and a PHP Tutorial here to create a REST API.
1.It dosent matter to PhoneGap where the PHP is hosted or Its PHP OR ASP.NET OR ASP.NET MVC
2.If You wanna host your PHP code yourself in production (You mayb shouldn't do this in production). then you need a server and a static IP address
3.if you just wanna setup a PHP server for developmental purposes then just tie it to 127.0.0.1:81 and you can directly use this address it doesn't matter whether you have a static IP address or not.
I have done this with phonegap using jsonp
http://en.wikipedia.org/wiki/JSONP
Works great

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 !!

SimpleTest - Web Browser - Transfer Authentication to Client

I'm not sure if this is even possible, but I figured this was a great place to ask the question.
I'm using http://simpletest.org/en/browser_documentation.html PHP WebBrowser to test a wordpress site. What I'm doing is setting the login credentials to access the wordpress backend. I run a couple of test, but my question is in certain situations I want to transfer the session that the "SimpleTest PHP Web Browser" has running to client's browser. Aka... my browser.
So in a since I"m transferring the session from the server side test browser to a normal client browser. This "client browser" is the same browser that is literally running the SimpleTest script to begin with.
I'm wondering if I can transfer the header & cookies associated with the "SimpleTest PHP Web Browser" to my browser. What I'm thinking is to pull the data out using the SimpleTest PHP Library and then set that information to the client browser using Javascript.
Is this even possible? I feel like I'm missing some basic understanding of server side session authentication which would make this impossible.
Any ideas? I'm really curious!
Did you look at the Authentication documentation for SimpleTest?

Categories