I made an application with PHP & jQuery mobile, and now I'm looking for how to convert this application to an apk file using PhoneGap.
Is it possible to do this? And are there any tutorials to help me learn how to do it?
Just change file extension . html to . php (index. html to index.
The strval() function is an inbuilt function in PHP and is used to convert any scalar value (string, integer, or double) to a string. We cannot use strval() on arrays or on object, if applied then this function only returns the type name of the value being converted. Return value: This function returns a string.
php, you can convert almost any PHP code into Python.
This is a fast a simple way to do it, it is better if you extended to make more real life usage:
1- download phonegap
2- Build your first app using this tutorial or using the phonegap how to get stared
3- once you have that let's go server side.. we need a API, the simplest way to do this is like this:
<?php
header('Access-Control-Allow-Origin: *');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
if($_GET['nameofFunction'] == 'getHomepageContent'){
require_once('controllers/homeController.php');
$objHome = new homeController();
$jsonReturn = $objHome->gethome();
echo($jsonReturn);
}
?>
4- create that controller to control the request from the API, for example something like this:
<?php
class homeController {
public function __contruct(){
}
public function gethome(){
//do what ever you need here, sql query, errors handling.. and return it
//back to the api.
//for example you could use something like this to return json array to the api
// without making much effort
if(mysql_num_rows($yourquery) > 0){
while($us = mysql_fetch_assoc($yourqueryResult)){
$output[]=$us;
$homeJsonResponse = json_encode($output);
}
return $homeJsonResponse;
}
}
?>
5- We are back to the phonegap application, now make sure you are including all needed files, jquery, jquerymobile, cordovajs, itouch, iscroll....
6- create the function that will execute on load and make the ajax call to the api, this will return json, just parse with jquery, and you are good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With