PHP code example of hxgf / x-utilities

1. Go to this page and download the library: Download hxgf/x-utilities 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/ */

    

hxgf / x-utilities example snippets


use VPHP\x;

x::email_send([
  'to' => '[email protected]',
  'from' => '[email protected]',
  'cc' => '[email protected]',  // optional
  'bcc' => '[email protected]',  // optional
  'reply-to' => '[email protected]',  // optional
  'subject' => 'Send me an email',
  'html' => true,  // optional, message will be sent as plain text unless this is true
  'message' => 'Right now...<br /><br /><br /><b><u>RIGHT NOW</u></b>'
]);

$_ENV['MAILGUN_API_KEY'] = 'key-f453654gg65sd6234r6rw5df6544e';
$_ENV['MAILGUN_DOMAIN'] = 'notifications.example.com';

echo x::client_ip();

echo x::url_slug('John User Name'); 
// john-user-name

echo x::url_strip('https://example.com/'); 
// example.com

echo x::url_validate('example.com'); 
// http://example.com

echo x::br2nl('This is a <br /> multi-line <br /> string!'); 
// This is a \n multi-line \n string!

echo x::array_encode(['Peter', 'Paul', 'Ringo', 'George']); 
// Peter|Paul|Ringo|George

$people = x::array_decode('Peter|Paul|Ringo|George');
print_r($people); 
// ['Peter', 'Paul', 'Ringo', 'George']

x::console_log(['example' => 'array']);

x::console_log(['example' => 'array'], [
  'format' => false, // removes all container formatting
  'style' => [ // defines custom styles for container formatting
    'font-size' => '16px',
    'background' => 'blue',
    'color' => 'yellow',
    'padding' => '2.5rem',
    'line-height' => '200%',
    'custom' => 'font-style: italic'
  ]
]);

x::dd(['example' => 'array']);

x::file_write('A string to append to a file', 'data.txt');

x::file_write(
  ['array_example' => 'An array to append to a file'], 
  'data.txt', 
  [
    'mode' => 'w+', // define PHP fopen mode, default is 'a'
    'line_beginning' => "\n- ", // prepend to beginning of input
    'line_ending' => "", // append end of input, default is PHP_EOL
  ]
);

x::error_log('Something bad happened.');