PHP code example of rnr1721 / le7-static-snippets

1. Go to this page and download the library: Download rnr1721/le7-static-snippets 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/ */

    

rnr1721 / le7-static-snippets example snippets


use Core\CodeParts\CodeSnippetsDefault;

    $codeSnippets = new CodeSnippetsDefault();

    // Here we register file
    // File must be exists!
    // If file not exists there are no error, only stub will be displayed
    $file1 = '/home/www/mysite.com/mydomain/snippet_top.txt';
    $file2 = '/home/www/mysite.com/mydomain/snippet_bottom.txt';
    $file3 = '/home/www/mysite.com/mydomain/snippet_middle.txt';
    // third parameter ts production or none
    $codeSnippets->register('snippets_top', $file1, true);
    $codeSnippets->register('snippets_bottom', $file2, true);
    $codeSnippets->register('snippets_middle', $file2, false);

    // Now we can read file contents to display it on web page
    // Second parameter is a defaults that will be displayed if file not exists or when it not production
    $result1 = $codeSnippets->get('snippets_top', '');
    $result2 = $codeSnippets->get('snippets_bottom', '');
    $result3 = $codeSnippets->get('snippets_middle', '');