I have a dynamic website, which heavily relies on PHP. I want to build a mobile application with it and want to modify my HTML code with PHP or simply just put PHP tags into my HTML document. I would need it to show content from other users (kind of like a blog).
Example:
<div id="content">
<?php echo "<div id='contentfromphp'>some content</div>"; ?>
</div>
Is this possible? If not does someone know a way to build a cross-platform app, where I can use this?
You should use AJAX, PHP won't run in Apache Cordova, from your server you can serve the PHP code and from your app you can load it.
file.php
<?php
//Your PHP Code to serving
?>
Script for ajax petition
function httpGet(yourUrl){
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", yourUrl,);
xmlHttp.send( null );
return xmlHttp.responseText;
}
In your onDocumentReady event
httpGet("http://path-to-your-server/php-script.php");