PHP Classes

File: examples/errors.php

Recommend this page to a friend!
  Classes of Victor Bolshov   PHP Validity Checker   examples/errors.php   Download  
File: examples/errors.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Validity Checker
Validate a set of values according to given rules
Author: By
Last change:
Date: 6 years ago
Size: 1,163 bytes


Class file image Download
<div class="col-sm-12 well">
    <?php if ($sent) : ?>
<?php if ($valid) : ?>
<p>Data is valid</p>
        <?php else : ?>
<p>Error summary as string (<i>FieldSet->getErrors()->toString()</i>)</p>
            <pre class="alert alert-danger"
                 style="white-space: pre-wrap"><?=htmlspecialchars($fieldSet->getErrors()->toString())?></pre>

            <p>Error summary as list (<i>FieldSet->getErrors()->toPlainArray()</i> &mdash; neatly formatted as HTML &lt;ul&gt;)</p>
            <ul class="alert alert-danger" style="list-style: none;">
                <?php foreach ($fieldSet->getErrors()->toPlainArray() as $field => $message) : ?>
<li><b><?=$field?></b>: <?=htmlspecialchars($message, ENT_QUOTES)?></li>
                <?php endforeach; ?>
            <p>Full error report (<i>FieldSet->getErrors()->export()</i> &mdash; json_encode()'d)</p>
            <pre class="alert alert-danger"
                 style="white-space: pre-wrap"><?=htmlspecialchars(json_encode($fieldSet->getErrors()->export()), ENT_QUOTES)?></pre>
        <?php endif; ?>
<?php endif; ?>