Nasıl Object Oriented Programming kullanarak bu kod artırabilir?

0 Cevap php

Object Oriented PHP ile ilgili gider ya da ben bir sınıfa HTML koyarak daha da geliştirmek gibi bu kadar olduğunu? Nasıl yapıyor hakkında gitmek istiyorsunuz? Not: Aşağıdaki kodu PEAR tarafından QuickForm kullanıyor. Şimdiden teşekkürler.

  <?php
    //MySQL class
    require_once('database/class.mysql.php');

    //Session class
    require_once('session/class.session.php');

    //SignUp class
    require_once('access/class.signup.php');

    //QuickForm class
    require_once('HTML/QuickForm.php');

    //PHPMailer class
    require_once('thirdparty/phpmailer/class.phpmailer.php');

    //Instantiate the MySQL class
    require_once('database/dbconnect.php');
    $db = &new MySQL($host, $dbUser, $dbPass, $dbName);

    //Instantiate the Session class
    $session = new Session;

     ?>

    <html>
        <head>
            <title>Test page</title>
        </head>
        <body>
            <?php
                //Instantiate Quickform
                $form = new HTML_QuickForm('regForm', 'POST');

                ///Header
                $form->addElement('header', null, 'Quickform tutorial example!');

                //First name
                $form->addElement('text', 'fname', 'First name:', array('size' => 30));
                $form->addRule('fname', 'Please enter your first name', 'required', null, 'client');

                //Last name
                $form->addElement('text', 'lname', 'Last name', array('size' => 30));
                $form->addRule('lname', 'Please enter your last name', 'required', null, 'client');

                //Password
                $form->addElement('password', 'pass', 'Password: ', array('size' => 30));

                //Gender
                $form->addElement('radio', 'sex', 'Gender: ', 'Male', 'male');
                $form->addElement('radio', 'sex', '', 'Female', 'female');

                //County
                $form->addElement('select', 'county', 'County:', array(
                    '0' => 'Select',
                    '1' => 'Louth',
                    '2' => 'Meath'
                ));

                //Date of Birth
                $form->addElement('date', 'dob', 'Date of Birth:', array('format' => 'dMY', 'minYear' => 1950, 'maxYear' => date('Y')));

                //Submit
                $form->addElement('submit', null, 'Submit');

                //Try to validate the form
                if ($form->validate()) {
                    echo 'Hello';
                }

                //Output the form
                $form->display();
            ?>
        </body>
    </html>

0 Cevap