Organizational Research By

Surprising Reserch Topic

boostr.in questions - Question:Stop class execution without terminating the script (Or includes)


In the class below, I need kill() to end whatever is going on within the class and just stop all and any processes WITHIN the class, not the script:

class email {
    //Expressions
    const exp_name      = "/^[A-Za-z .'-]+$/";
    const exp_email     = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    const error         = "We are sorry, but there appears to be a problem with the form you submitted.
";
    private $msg        = 'Thank you for subscribing';
    protected $status   = true;

    function __construct() {
        self::validate();
        echo '
the CLASS continued
';
    }

    private function validate() {
        //Empty fields
        foreach ($_REQUEST as $key => $value) {
            $val = str_replace( ' ', '', $value );
            if ( $val === '' ) {
                self::error( 'empty', $key );
                self::kill(); //If empty, this should end the loop and class
            } //if:empty
        } //foreach

        //Validate Name
        if( !preg_match(self::exp_name,$_POST['Name']) ) {
            self::error( 'name' );
            self::kill(); //kill
asked Sep 13, 2013 in PHP by rajesh
edited Sep 12, 2013
0 votes
22 views



Related Hot Questions



Government Jobs Opening


...