PHP code example of krishnapawar / php-html-builder

1. Go to this page and download the library: Download krishnapawar/php-html-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

krishnapawar / php-html-builder example snippets


use KrishnaPawar\HtmlBuilder\Html;

// Link
echo Html::link("https://example.com", "Visit Website", ["target" => "_blank"]);

// Image
echo Html::image("logo.png", "Website Logo");

// Inline CSS
echo Html::style("body { background-color: #f4f4f4; }");

// Inline JavaScript
echo Html::script("console.log('Hello, World!');");

// External CSS
echo Html::stylesheet("https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css");

// External JavaScript
echo Html::scriptSrc("https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js");

use KrishnaPawar\HtmlBuilder\Form;

// Open Form
echo Form::open("submit.php", "POST");

// Input Fields
echo Form::input("name", "text", "", ["placeholder" => "Enter Name"]);
echo Form::input("email", "email", "", ["placeholder" => "Enter Email"]);

// Select Dropdown
echo Form::select("role", ["admin" => "Admin", "user" => "User"], "user");

// Checkbox
echo Form::checkbox("subscribe", "yes", true);

// Submit Button
echo Form::submit("Send");

// Close Form
echo Form::close();

use KrishnaPawar\HtmlBuilder\Form;

// Modal Example
echo Form::modal(
    "myModal",
    "My Modal Title",
    "<p>This is a simple modal body.</p>",
    "<button class='btn btn-primary'>Save Changes</button>"
);