Reference - PAD functions - bytes


App: manual - Page: fragments/expressions_31


App: manual - Page: fragments/pipes_5
PHP
fragments/pipes_5.php
HTML
fragments/pipes_5.pad
Result
<?php

$intro
= 'The quick brown fox jumps over the lazy dog, twice before breakfast';
$title = 'Crème Brûlée & Co.';
$size = 3221225472;
$quote = 'it\'s </script>';

?>
<p>{$intro | truncate(30)}</p>
<p>?page={$title | slug}</p>
<p>{$size | bytes}</p>
<p>{$quote | escape('js')}</p>


App: regression/framework - Page: functions/bytes_rounds_before_it_chooses_the_unit
PHP
HTML
functions/bytes_rounds_before_it_chooses_the_unit.pad
Result
[{echo 1048575 | bytes(0)}][{echo 1048575 | bytes}][{echo 1023.996 | bytes(1)}][{echo 1536 | bytes}]


App: regression/framework - Page: functions/bytes_writes_a_size_for_people
PHP
HTML
functions/bytes_writes_a_size_for_people.pad
Result
[{echo 1536 | bytes}][{echo 3221225472 | bytes}][{echo 500 | bytes}][{echo 123456789 | bytes(1)}]


App: regression/framework - Page: helpers/numbers_file_size_is_the_bytes_pipe_s_answer
PHP
helpers/numbers_file_size_is_the_bytes_pipe_s_answer.php
HTML
helpers/numbers_file_size_is_the_bytes_pipe_s_answer.pad
Result
<?php

// padNumberFileSize: units of 1024, the unit chosen on the size as it will be written,
// at most precision decimals - 0 unless given, where the bytes pipe has 2.

$r = json_encode ( [
padNumberFileSize ( 1536 ),
padNumberFileSize ( 1536, 1 ),
padNumberFileSize ( 1536, 2 ),
padNumberFileSize ( 1048575 ),
padNumberFileSize ( 1023.996, 1 ),
padNumberFileSize ( 3221225472 ),
padNumberFileSize ( 123456789, 1 ),
padNumberFileSize ( 500 ),
padNumberFileSize ( 0 ),
padNumberFileSize ( '2048' ),
padNumberFileSize ( NULL )
] );

$size = 123456789;

?>
{!r} {$size | bytes(1)} {$size | bytes} {echo 1536 | bytes}