PHP code example of webfiori / php-structs

1. Go to this page and download the library: Download webfiori/php-structs 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/ */

    

webfiori / php-structs example snippets

 php
$document = HTMLNode::fromFile('my-html-file.html', [
    'page-title' => 'Hello Page',
    'page-desc' => 'A page that shows visits numbers.',
    'mr-name' => 'Ibrahim Ali',
    'visit-number' => 33,
]);
echo $document
 php
<div>
     
    if (count($posts) != 0) {
 php
$posts = [
  'Post 1',
  'Post 2',
  'Post 3'
];

$node = HTMLNode::fromFile('posts-list.php', [
  'posts' => $posts
])
 php
$xml = new HTMLNode('saml:Assertion', [
   'xmlns:saml' => "urn:oasis:names:tc:SAML:2.0:assertion",
   'xmlns:xs' => "http://www.w3.org/2001/XMLSchema",
   'ID' => "_d71a3a8e9fcc45c9e9d248ef7049393fc8f04e5f75",
   'Version' => "2.0",
   'IssueInstant' => "2004-12-05T09:22:05Z",
]);
$xml->addChild('saml:Issuer')->text('https://idp.example.org/SAML2');

echo $xml->toXML();
//Output:
/*
<?xml version="1.0" encoding="UTF-8"