Reference - Output types - console


App: cli - Page: index
PHP
HTML
index.pad
Result
Hello world


App: regression/output_console - Page: broken
PHP
HTML
broken.pad
Result
<p>{ajax 'no/such/page/with/a/name/long/enough/to/pass/the/cut', app='regression/output_console'}</p>


App: regression/output_console - Page: error
PHP
error.php
HTML
error.pad
Result
<?php

// The console writer's error report: the page that fails is answered with the message
// whole - it was cut at 100 characters, which on the engine's own file path and line
// left 'there is no page named ...' without the name of the page. Fetched as a browser
// would: a curl caller is answered by the JSON channel instead (error/claude.php).

$r = padCurl ( [ 'url' => $padHost . 'regression/output_console/?broken&padInclude',
'options' => [ 'USERAGENT' => 'Mozilla/5.0 pad' ] ] );

$whole = ( $r ['result'] == '500'
and str_contains ( $r ['data'], "there is no page named 'no/such/page/with/a/name/long/enough/to/pass/the/cut' in the application 'regression/output_console'" ) ) ? 'yes' : 'NO';

// A visitor from elsewhere - a forwarded request is somebody else's (error/claude.php) -
// gets the request id and nothing more, as under every other output type: the console
// report went to anyone, the server's paths and the template's source with it.

$far = padCurl ( [ 'url' => $padHost . 'regression/output_console/?broken&padInclude',
'headers' => [ 'X-Forwarded-For' => '203.0.113.9' ],
'options' => [ 'USERAGENT' => 'Mozilla/5.0 pad' ] ] );

$hidden = ( $far ['result'] == '500'
and preg_match ( '/^Error: [A-Za-z0-9]{8}$/', trim ( $far ['data'] ) ) ) ? 'yes' : 'NO';

?>
<p>the error report is whole: <b>{$whole}</b></p>
<p>and kept from a visitor: <b>{$hidden}</b></p>


App: regression/output_console - Page: index
PHP
index.php
HTML
index.pad
Result
<?php

// The console writer's promise: the page echoed straight to the client, nothing but the
// body - and none of the headers the web writer decorates a response with, which is
// what separates it from web. padCurl trims what it fetches, so the closing newline the
// writer adds cannot be asserted here; the exact body can.

$r = padCurl ( $padHost . 'regression/output_console/?payload&padInclude' );

$verdict = ( $r ['result'] == '200'
and ! isset ( $r ['headers'] ['PAD'] )
and
$r ['data'] == '<p>CARRIED ALL THE WAY</p>' ) ? 'yes' : 'NO';

$output = 'console';

?>
<p>output type: {$output}</p>
<p>the payload arrived as this type promises: <b>{$verdict}</b></p>


App: regression/output_console - Page: payload
PHP
payload.php
HTML
payload.pad
Result
<?php

$greet
= 'carried all the way';

?>
<p>{$greet | upper}</p>