PHP 5.3 support was added by Ben Ramsey after initial release
<!-- HelloWorld\Resources\index.html --> <html> <head> <title>Array Sum Demo</title> </head> <body style="background-color:#1c1c1c;margin:0;"> <div style="border-top:1px solid #404040;"> <div style="color:#fff;padding:10px;"> <script type="text/php"> $numbers = range(1, 5); $document->write(array_sum($numbers)); </script> </div> </div> </body> </html>
JS to PHP | PHP to JS |
---|---|
Number (floating point) to double | double/float/int to Number (floating point) |
Boolean to boolean | boolean to Boolean |
null / undefined to null | null to null |
String to string | string to String |
Object to object | object to Object |
Array to (SPL) ArrayObject-like object | enumerated array to Array, associated array to Object |
<!-- HelloWorld\Resources\index.html --> <html> <head> <title>jQuery Demo</title> <style type="text/css"> body {background-color:#1c1c1c;margin:0;} #foo_button {margin:10px;} #foo {display:none;color:white;background-color:black;padding:10px;} </style> </head> <body> <input id="foo_button" type="button" value="Click Me" /> <div id="foo">PHP using jQuery</div> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/php"> $jQuery()->ready(function() use (&$jQuery) { $jQuery("#foo_button")->live("click", function() use (&$jQuery) { $jQuery("#foo")->fadeIn(2000); }); }); </script> </body> </html>Credit: Ed Finkler
<!-- HelloWorld\Resources\index.html --> <html> <head> <title>Including PHP Demo</title> </head> <body> <script type="text/php" src="phpinfo.php" /> <!-- The above is equivalent to this --> <script type="text/php"> phpinfo(); </script> </body> </html>
<!-- HelloWorld\Resources\index.html --> <html> <head> <title>Including PHP Demo</title> </head> <body> <script type="text/php"> include("phpinfo.php"); </script> </body> </html>
require_once
does not workecho
and phpinfo()
usually output to console, not the current document\
when used in <script>
tags<!-- HelloWorld\Resources\index.html --> <html> <head> <title>Titanium UI API Demo</title> </head> <body> <script type="text/php"> $file = $Titanium->UI->createMenuItem("File"); $file->addItem("Quit", function() use ($Titanium) { $Titanium->App->exit(); }); $menu = $Titanium->UI->createMenu(); $menu->appendItem($file); $Titanium->UI->setMenu($menu); </script> </body> </html>
Needs a patch to run on Titanium 1.1.0+