PHP generates HTML files, summerhtml

Source: Internet
Author: User

2018-6-27 20:13:04 Wed

If you edit a page with multiple select/option tags or multiple checkbox/radio tags, select one of the items by default

The previous wording has Vue's model, Javascript+ajax plan to modify

But still feel the PHP code proficiency, simply write a PHP generated HTML document class,

Expect it to output a complete HTML document, or to output a partial label:

Code or prototype, just can be used, supporting a few tags: code cloud Look test.php file, is the introduction of usage

1. Generate some tags for the HTML header

1 // Generate head 2 $html = Html::ini ()->setlang (' en ')->settitle (' Auto-generated HTML file ')->setmetaname (' keyword ', ' auto-generated HTML ' )3     ->css (' http://aaa.css ')4     ->css (' http://bbb.css ')  5     ->js (' http://jquery1.js ')6     ->js (' http://jquery2.js ') )7     ->sethead ();

2. Generate Table Labels

1 //Generate Table2 $data= [3[' A ', ' B ', ' C ', ' d '],4[' A ', ' B ', ' C ', ' d '],5[' A ', ' B ', ' C ', ' d '],6[' A ', ' B ', ' C ', ' d '],7[' A ', ' B ', ' C ', ' d '],8 ];9 Ten $body=Newbody (); One $table= Table::ini ()->setclass (' MyTable ')); A  - foreach($data  as $k 1=$tds) { -     $tr= Tr::ini ()->setid (' Tr_ ').$k 1); the     foreach($tds  as $k 2=$v 2) { -         $TD= Td::ini ()->settext ($v 2)->setid (' Td_ ').$k 1.‘ _‘.$k 2); -         $tr->TD ($TD); -     } +     $table->TR ($tr); - } +  A $body->append ($table);

3. Generate Select/option and select one of the items by default

1 $select= Select::ini ()->setid (' select_id '));2 $options= [' A1 ' + 1, ' A2 ' and ' = 2, ' A3 ' and 3];3 foreach($options  as $name=$value) {4     $option= Option::ini ()->settext ($name)->setvalue ($value);5     $value= = 2 &&$option->setselected (TRUE);6     $select->option ($option);7}

4. Add Select/input to the form label

1 $form= Form::ini ()->setid (' MyForm ')->setclass (' Formclass ')->setmethod (' Post ')->setaction ('/HTTP/ Www.test5.com/submit ');2 3 $form->append (Input::ini ()->setid (' A1 ')SetType(' Hidden ')->setname (' A1 ')->setvalue (1));4 $form->append (Input::ini ()->setid (' A2 ')SetType(' text ')->setname (' A2 ')->setvalue (2));5 $form->append (Label::ini ()->settext (' Drop down marquee '));6 7...8 9 Ten $form->append ($select);

5. Add a label to the body tag

// Add form to body $body->append ($form);

6. Add the body tag to the HTML tag and return to the final HTML document

// Add body to HTML $str $html->setbody ($body)->out ();

PHP generates HTML files, summerhtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.