PAD - PHP Application Driver


home | manual | reference | regression | sequence | develop | apps


Counter

OLD NEW  go  ok

This page tracks how many times it has been viewed.

Total Page Views

12

Statistics

Metric Value
Total Views (all time) 12
Views Today 12
Current Date Sunday, January 18, 2026

The counter increments each time this page is loaded. Daily counts reset at midnight.

This page tracks how many times it has been viewed.

Total Page Views

17

Statistics

Metric Value
Total Views (all time) 17
Views Today 17
Current Date Sunday, January 18, 2026

The counter increments each time this page is loaded. Daily counts reset at midnight.

Old Source New Source
<p>This page tracks how many times it has been viewed.</p>

<h2>Total Page Views</h2>

<div class="counter">
<p>This page tracks how many times it has been viewed.</p>

<h2>Total Page Views</h2>

<div class="counter">
12 17
</div>

<h2>Statistics</h2>

<table>
<tr>
<th>Metric</th>
<th>Value</th>
</tr>
<tr>
<td>Total Views (all time)</td>
</div>

<h2>Statistics</h2>

<table>
<tr>
<th>Metric</th>
<th>Value</th>
</tr>
<tr>
<td>Total Views (all time)</td>
<td><strong>12</strong></td> <td><strong>17</strong></td>
</tr>
<tr>
<td>Views Today</td>
</tr>
<tr>
<td>Views Today</td>
<td><strong>12</strong></td> <td><strong>17</strong></td>
</tr>
<tr>
<td>Current Date</td>
<td>Sunday, January 18, 2026</td>
</tr>
</table>

<p style="color: #999; font-size: 12px; margin-top: 20px;">
The counter increments each time this page is loaded. Daily counts reset at midnight.
</p>
</tr>
<tr>
<td>Current Date</td>
<td>Sunday, January 18, 2026</td>
</tr>
</table>

<p style="color: #999; font-size: 12px; margin-top: 20px;">
The counter increments each time this page is loaded. Daily counts reset at midnight.
</p>

PHP
counter.php
HTML
counter.pad
Result
<?php

$title
= 'Page Counter';
$dataFile = DAT . 'demo/counter.json';

if ( !
is_dir ( DAT . 'demo' ) )
@
mkdir ( DAT . 'demo', 0755, TRUE );

$data = [ 'total' => 0, 'today' => 0, 'date' => date ( 'Y-m-d' ) ];
if (
file_exists ( $dataFile ) ) {
$json = file_get_contents ( $dataFile );
$data = json_decode ( $json, TRUE ) ?: $data;
}

if (
$data ['date'] != date ( 'Y-m-d' ) ) {
$data ['today'] = 0;
$data ['date'] = date ( 'Y-m-d' );
}

$data ['total']++;
$data ['today']++;

file_put_contents ( $dataFile, json_encode ( $data, JSON_PRETTY_PRINT ) );

$totalCount = $data ['total'];
$todayCount = $data ['today'];
$currentDate = date ( 'l, F j, Y' );

?>
<p>This page tracks how many times it has been viewed.</p>

<h2>Total Page Views</h2>

<div class="counter">
{$totalCount}
</div>

<h2>Statistics</h2>

<table>
<tr>
<th>Metric</th>
<th>Value</th>
</tr>
<tr>
<td>Total Views (all time)</td>
<td><strong>{$totalCount}</strong></td>
</tr>
<tr>
<td>Views Today</td>
<td><strong>{$todayCount}</strong></td>
</tr>
<tr>
<td>Current Date</td>
<td>{$currentDate}</td>
</tr>
</table>

<p style="color: #999; font-size: 12px; margin-top: 20px;">
The counter increments each time this page is loaded. Daily counts reset at midnight.
</p>

This page tracks how many times it has been viewed.

Total Page Views

18

Statistics

Metric Value
Total Views (all time) 18
Views Today 18
Current Date Sunday, January 18, 2026

The counter increments each time this page is loaded. Daily counts reset at midnight.




home | manual | reference | regression | sequence | develop | apps

(c) 2003-2025 Herbert Groot Jebbink