PAD in the browser

PAD also runs on PHP compiled to WebAssembly, inside a browser tab, with no PAD server at all. php wasm/build.php bundles the engine into one file, and the page wasm/ loads PHP into the tab, writes the engine into its memory and renders the template you type with the JSON data beside it - the example below, on this server, is the page's sample:

PHP
fragments/pad_in_the_browser_1.php
HTML
fragments/pad_in_the_browser_1.pad
Result
<?php

$title
= 'Fruit';
$items = [ [ 'name' => 'Apple', 'stock' => 3 ], [ 'name' => 'Pear', 'stock' => 0 ] ];

?>
<h2>{$title}</h2>
<ul>
{items}
<li>{$name}{if $stock eq 0} - sold out{/if}</li>
{/items}
</ul>

Fruit

  • Apple
  • Pear - sold out

A whole application runs in the browser the same way, its SQLite database kept there between visits, opened from the disk or installed from an https host: Offline applications.